delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/06/04/17:30:06

Date: 4 Jun 2000 14:29:23 -0700
Message-ID: <20000604212923.19988.cpmta@c012.sfo.cp.net>
X-Sent: 4 Jun 2000 21:29:23 GMT
Mime-Version: 1.0
To: djgpp AT delorie DOT com
From: frans nagel <fransrn AT altavista DOT com>
X-Mailer: Web Mail 3.6.3.1
Reply-To: djgpp AT delorie DOT com

hello Djgpp

I was hoping you would have time to help me.
I have a difficulty storing classes to Random Access files.I use the seekp,seekg, and read and write functions but end up with data that are pushing each other out of position in the file.
I checked with tellp()and that showed me that when the program writes a record it writes past  its allotted position by 2 or up to 8 spaces,whatever it seems to feels like.
How do I make sure this doesn't happen?
this is an excerpt:

 inout.seekp((num-1)*40);
  cout<<"start write"<<inout.tellp();
inout.write(reinterpret_cast<const char*>(&client),40);
cout<<"after write"<<inout.tellp()<<endl;}

startwrite here yields 40
after write yields 88
that's 8 spaces into the next record

I appreciate any advice you may have
Frans Nagel


_______________________________________________________________________

Why pay when you don't have to? Get AltaVista Free Internet Access now! 
http://jump.altavista.com/freeaccess4.go

_______________________________________________________________________

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019