I want to open mulitiple files and I use the same filestream each time, opening and closing the file stream each time that I need to read a file.
ifstream ifStr;
while()
{
ifStr.open();
....
....
....
....
....
ifStr.close();
}
Problem is that I can only open one file successfully, and no matter what I do, IF I use the same file stream,(ifStr) to open the second/third/....nth file, I cant do that.
The filename, path etc are fine because this does work:
ifstream ifStr1;
ifStr1.open( "filename1" );
....
....
....
....
....
ifStr1.close();
ifstream ifStr2;
ifStr2.open( "filename2" );
....
....
....
....
....
ifStr2.close();
So as I see it, I cant use the *same* file stream twice/mulitple times within the same scope, even though I do close the file each time.
What am I doing wrong?