I'm having problems with the getline instruction from fstream. this is a snippet from my code:
boolean_1=true;
while(true)
{
if(boolean_1)
{
//some stuff
}
else
{
save_file.open("save.txt", fstream::in);
//some stuff
save_file.close();
}
mission_file.open(filename, fstream::in);
mission_file.getline(buffer_line, 256);
//some other stuff
boolean_1=false;
save_file.open("save.txt", fstream::out);
//write something
save_file.close();
}
This code should open the mission_file the first time it runs, and open a save file at the next iteration. The save file is created at the end of every cycle. At least it should work like this. Because, the first time everything works flawlessly, but in the next iteration, "mission_file.getline(buffer_line, 256);" returns an empty line, making the program crash. Also, if boolean_1 starts as false, the cycle works fine until the next one.
I have already checked the existence of the required ".txt"s, both mission_file and save_file return is_open() true.