c++ - iostream trouble
- Steve & Denise De Chellis (23/23) Apr 26 2002 I'm writing a very basic io function one for loading and one for saving.
- Roland (4/27) Apr 29 2002 may be DM correctly does no alow you to save the race as this informatio...
I'm writing a very basic io function one for loading and one for saving. Load: fstream infile; infile.open (szFile, fstream::in ); // All variables go here infile.getline(szName,40) ; infile.getline(szRace,30) ; infile.getline(szSex,10) ; Save: fstream outfile; outfile.open (szFile, fstream::out ); // All variables go here outfile << szName << endl; outfile << szRace << endl; outfile << szSex << endl; outfile << szHandeness << endl; outfile << szBirthCircumstance << endl; outfile << szLegit << endl; The problem I have is that szName loads properly, but the next variable (szRace)ends up loading the string for szLegit minus the first character! What the heck am I doing wrong? Thanks Steve
Apr 26 2002
Steve & Denise De Chellis a écrit :I'm writing a very basic io function one for loading and one for saving. Load: fstream infile; infile.open (szFile, fstream::in ); // All variables go here infile.getline(szName,40) ; infile.getline(szRace,30) ; infile.getline(szSex,10) ; Save: fstream outfile; outfile.open (szFile, fstream::out ); // All variables go here outfile << szName << endl; outfile << szRace << endl; outfile << szSex << endl; outfile << szHandeness << endl; outfile << szBirthCircumstance << endl; outfile << szLegit << endl; The problem I have is that szName loads properly, but the next variable (szRace)ends up loading the string for szLegit minus the first character! What the heck am I doing wrong? Thanks Stevemay be DM correctly does no alow you to save the race as this information is useless <> roland
Apr 29 2002