www.digitalmars.com         C & C++   DMDScript  

c++ - iostream trouble

reply "Steve & Denise De Chellis" <dbouton snet.net> writes:
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
parent Roland <rv ronetech.com> writes:
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
Apr 29 2002