Message-ID: <36DE993F.35DEE66E@solutions2000.net> Date: Thu, 04 Mar 1999 09:31:27 -0500 From: Nehru Juman X-Mailer: Mozilla 4.04 [en] (Win95; I) MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: (Problem with structs) References: <36DDBF84 DOT 438669BC AT solutions2000 DOT net> <36DDC82A DOT B973BDBA AT unb DOT ca> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Thank you very much for the help. My program works fine now. Endlisnis wrote: > Nehru Juman wrote: > > > I'm having a problem with a program I took directly from a c++ book ("A > > Beginners C++) which involves writing structs to disk. Since it comes > > from the book I assume it should work. I wrote a simplified program to > > isolate the problem. Can anybody tell me why the below code doesn't > > work properly: > > [snip] > > > alpha beta[20]={{10,"abcd"},{20,"efgh"},{30,"ijkl"}, ^^ > note the 10.[snip] > > > gDataFile.open("testfile.my",ios::in|ios::out); > > The problem is with the DOS implimentation of "newline"s. In DOS, a > 'newline' is represented as CR, LF (13,10). And for fstream to write text > files that standard text editors can read, any time you try to write byte > value 10, a byte value 13 is written as well. You can override this in the > open line: > gDataFile.open("testfile.my",ios::in|ios::out|ios::binary); > That fixes the problem (I tried it, and it works). > -- > (\/) Endlisnis (\/) > s257m AT unb DOT ca > Endlisnis AT GeoCities DOT com > Endlisnis AT BrunNet DOT Net > Endlisnis AT HotMail DOT com