There is a simple example. I open the cmd command line, enter the path to * .exe and the name of the text document: C: \ Windows \ system32> "... exe" "in1.txt". At the exit I get
first
Hello!
And second'a no!
The problem is in reading through the command line, if this manipulation is removed, then the second is perfectly displayed.
#include <string> #include <fstream> #include <iostream> using namespace std; void first(string& s1,ifstream& in) { in >> s1; // тут считывается файл со строкой first in.close(); } void second(string& s2) { ifstream in2("in2.txt"); //тут записано second in2 >> s2; in2.close(); } int main(int argc, char **argv) { if (argc != 2) { cerr << "\nError.";exit(-1); } ifstream in(argv[1]); string s1,s2; first(s1, in); //in.close(); second(s2); cout << s1<<endl; cout << "Hello!"<<endl; cout<< s2; system("pause>void"); return 0; } How to solve this problem?
pausecommand in thevoidfile? - Harryin2.txtfile. - AnT