Hi. I'm trying to use ofstream to save the data for the game I'm coding, but I've hit a snag. When it saves the game, for some reason it outputs a null character to the start of the file, meaning that it can't load again properly. clear() and pause(1) are functions that I wrote to clear the screen and wait for any key, respectively, and they work fine. The saveto << line is just broken up so that it wraps right here, it's all one line in the code.
Code:
int save()
{
clear();
cout<<"Saving game...\n";
ofstream saveto ( "stockmarket.sav" ); //Open file to save to and input data, comma-delimited
saveto.seekp ( 0 );
saveto << playername <<","<< cash <<","<< boom <<","<< recession <<","<< gi <<","<< gic <<","<< paid <<","<< week <<
","<< gamelength <<","<< stock[0] <<","<< stock[1] <<","<< stock[2] <<","<< stock[3] <<","<< stock[4] <<","<< stock[5] <<
","<< stock[6] <<","<< stock[7] <<","<< stock[8] <<","<< stock[9] <<","<< value[0] <<","<< value[1] <<","<< value[2] <<
","<< value[3] <<","<< value[4] <<","<< value[5] <<","<< value[6] <<","<< value[7] << ","<< value[8] <<","<< value[9];
saveto.close(); //Close save file
cout<<"Game saved successfully!\n";
pause(1);
}