Possible Duplicate:
C++ can I reuse fstream to open and write multiple files?
why is it not possible to use one ifstream variable for opening one file, reading it, then closing it and, after that, opening another file, reading and closing, etc? How would that look in code (let's just say each file has an integer inside):
int k, l;
ifstream input1;
input1.open("File1.txt");
input1 >> k;
input1.close();
input1.open("File2.txt");
input1 >> l;
input1.close();
the only way I solved the problem was creating another ifstream variable.