Snake174, ну void для подпрограмм или функциями их еще называют
Код | void EnterFileName1(const char*); ...... void EnterFileName1(const char*std) { std::string name; std::cin >> name; std::ifstream ifs(name.c_str()); }
|
как-то так....но это не правильно
а вот весь код, но в нем куча ошибок....
Код | #include <fstream> #include <algorithm> #include <iterator> #include <vector> #include <sstream> #include <vcl.h> #include <iostream> #include <conio.h> #include <cstdlib> #include <ctime>
#pragma hdrstop using namespace std; #pragma argsused
void EnterFileName1(const char*); void EnterFileName2(const char*); void ProcessingFile(); void result(char*, char*); void ShowMenu();
void EnterFileName1(const char*std) { std::string name; std::cin >> name; std::ifstream ifs(name.c_str()); }
void EnterFileName2(const char*std) { std::string name1; std::cin >> name1; std::ofstream o(name1.c_str()); }
void ProcessingFile(char*std, char*o) { if (!ifs) return 1; std::string str; while (!ifs.eof() && std::getline(ifs, str)) { std::istringstream ist(str); std::vector<std::string> v; std::copy(std::istream_iterator<std::string>(ist), std::istream_iterator<std::string>(), std::back_inserter(v)); std::swap(*v.begin(), *(v.begin() + v.size() / 2)); std::copy(v.begin(), v.end(), std::ostream_iterator<std::string> (o, " ")); o << std::endl; } }
void result(char*text, char*buf) { char text[500], buf[500]; cout << "Enter the final name file: "; cin >> text; ifstream f(text, ios::in); if (!f) { cout << "Error of opening of a file."; } while (!f.eof()) { f.getline(buf, 500); cout << buf << endl; }
int main()
cout << "Welcome! Enter a command:"<< endl; int command = showMenu(); switch (command)
{ case 1: cout << "Enter a processed file name:"<<endl ; EnterFileName1(const char*str); cout << "Enter a final file name:"<<endl ; EnterFileName2(const char*str); std::ofstream o(name1.c_str()); if (! ifs && ! o)
{ cout<<"wrong file name!"; exit (1); }
else { ProcessingFile(char*str) cout << "change of the file is successfully complete!"<<endl ; } break;
case 2: void result(char*text, char*buf) break;
case 3: return; break;
} void ShowMenu(); { int command = 0; while(true){
cout << "1. changing of the first and average word in a line of the file " << endl; cout << "2. see result" << endl; cout << "3. Exit" << endl;
cin >> command; if (command >=1 && command <=3) return command; cout << "You have entered a wrong command. Please repeat your choice:" << endl;
if (cin.fail()){ cin.clear(); cin.sync(); } } }
|
|