Date: Sun, 24 Nov 1996 11:28:26 +0200 (IST) From: Eli Zaretskii To: Faulkner Cc: djgpp AT delorie DOT com Subject: Re: strange file writing/reading problem In-Reply-To: <3295D2C1.4D5@southcom.com.au> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Sat, 23 Nov 1996, Faulkner wrote: > Here's a problem for the DJGPP people of the world. > I've got 2 structures, a VertexType and a PolygonType, both are simple > and short structures. I write 20 vertices to a file, then 20 polygons > to a file. When I read the file back into memory any element that > has the no. 13 in it goes screwy!!!! (dont worry, I've checked for > viruses). You write the file in binary mode (which is correct), but read it in text mode (which is incorrect). Change this line: fp=fopen(argv[1], "r"); to say this: fp=fopen(argv[1], "rb"); then try again.