I initialized an ifstream and opened a file from argv[1], then closed the ifstream when I finished dealing with that file. Later, I try to use getline with cin, but for some reason it begins to read from the file opened in ifstream. How can I fix this? This only happens on terminal in mac and in xcode, when my friend tested it on cygwin, it worked fine.
string arg = (string)argv[1];
ifstream fin(arg);
if(arg == "--help" || arg == "-h"){
cout << "help message\n";
return 0;
}
string full;
while(getline(fin, full)){
//do stuff
}
fin.close();
string f2;
while(getline(cin, f2)){
//do stuff
}
Aucun commentaire:
Enregistrer un commentaire