void do_event(string filename, int eventindex) { //code for loading events
ifstream eventfile( filename.c_str(), ios::in | ios::app );
bool scanning = true;
eventfile.get( emptyvalue, 8 );
eventfile.get( tempvalue, 4 );
while (scanning) {
if ( atoi(tempvalue) == eventindex ) {
//the event we're scanning for
eventfile.get( emptyvalue, 1 );
eventfile.get( tempvalue, 2 );
if ( strcmp( tempvalue, ">>" ) == 0 ) { //end of event
eventfile.close();
scanning = false;
}
}
else {
//not the event we're scanning for
eventfile.getline( emptyvalue, 1 );
//try the next line
}
}
}
This results in a Runtime error. I expect it's because of the loop, but it should close the file and end the loop when it gets to ">>", which I have in the file at the right place.