home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!munnari.oz.au!bunyip.cc.uq.oz.au!griffin!kurango!gucis!jetherid
- From: jetherid@gucis.cit.gu.edu.au (Jason Etheridge)
- Subject: File I/O using C++ (write/read objects...)
- Message-ID: <1992Aug26.023255.10785@gucis.cit.gu.edu.au>
- Organization: Griffith University, Brisbane, Australia.
- Date: Wed, 26 Aug 92 02:32:55 GMT
- Lines: 19
-
- I am having real problems reading and writing objects to a file. A text
- I have uses
-
- out.write((unsigned char*) &object, sizeof(OBJECT))
-
- where out is an fstream that allows writing to the file it is open for,
- and object is an object of class OBJECT.
-
- It writes the object, seemingly with no problems, but when I try and read
- it back in the resulting object has been garbled, it's attributes changed
- with the occasional garbage character.
-
- Strangely enough, if I try this with an object with no functions, it
- works perfectly.
-
- Can anyone suggest a good way of writing and reading objects to a file
- that really works?
-
- (I am using the Borland C++ 3.0 compiler)
-