April 27, 2002 iostream trouble | ||||
---|---|---|---|---|
| ||||
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 |
April 29, 2002 Re: iostream trouble | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steve & Denise De Chellis |
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
> Steve
may be DM correctly does no alow you to save the race as this information is useless <>
roland
|
Copyright © 1999-2021 by the D Language Foundation