www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - iostream trouble

↑ ↓ ← "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
↑ ↓ → 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