I have two files listed in “input.txt”, I can read in the first one using:
while (getline(inFile, name))
{
datFile.open(name, ifstream::in);
...
}
But when it gets to the end of processing datFile, it will go back and try to open the other file (second file listed in “input.txt”, which I do not want to process the same way. How can I open the second file and process it differently than the first?
Thanks.
If you are guaranteed to have two files in your input.txt file (inFile), take getline out of a while loop… call it once to get the first file, process it, then call it again and process the second file after the first one is done.
Alternatively, you could use break to exit the while loop as soon as datFile is done processing… but that isn’t as sound logically.