Hello guys!
I'm having a rather pesky problem working with fstream.
I could write, for example:
fstream file("text.txt");
then file should be open in read/write mode.
But then if I do the following:
file << "Some text";
file >> string_var;
or in the opposite order, it will only perform the first operation. I've even tried with seekp() but it still happens, even if I do:
file.open("text.txt",ios::out);
file << "A word!";
file.close();
file.open("text.txt",ios::in);
file >> aString;
The only way i've found to fix this is creating two separate fstreams but it seems not right...
Also, if I try to open different files in a loop using only one fstream the same happens.
Is all this supposed to happen? What am i doing wrong?