From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 10755 invoked from network); 27 Apr 1998 02:50:39 -0000 Received: from winnie.fit.edu (163.118.5.1) by mail2.redhat.com with SMTP; 27 Apr 1998 02:50:39 -0000 Received: from ee.fit.edu (yacht.ee.fit.edu [163.118.30.1]) by winnie.fit.edu (8.8.7/8.8.7) with SMTP id WAA03539 for ; Sun, 26 Apr 1998 22:46:41 -0400 (EDT) Received: from localhost by ee.fit.edu (SMI-8.6/SMI-SVR4) id WAA23733; Sun, 26 Apr 1998 22:49:43 -0400 Date: Sun, 26 Apr 1998 22:49:43 -0400 (EDT) From: Christopher Curtis To: axp-list@redhat.com Subject: Re: Problem with binary file I/O In-Reply-To: <199804270056.SAA02075@walleye.gonefishing.sk.ca> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Sun, 26 Apr 1998, Larry Zimmerman wrote: > When I use the "high-level" file I/O functions, the program fails. > When I use the "low-level" functions, the program works. [...] > no-one believes me, or maybe no-one knows how to fix it! This seems unlikely... > I wrote a test program to demonstrate the problem - see link below - > and have discovered the following: [...] > I have a web page with more details and the sample program at: > http://walleye.gonefishing.sk.ca/laz/rdwr/problem.html I looked at the .c file you have at this link and the problem seems pretty simple. Maybe that's why nobody answered, or maybe everyone's working on the Netscape code. Anyhow, on pages 11 and 13 (of 22 - you do the math) you have two fopen calls, each opening the file in "a+" mode. In this mode, fseek()s will work and you can read data from any position, but all data written will ALWAYS be written to the end of the file. This is 'append' mode and was created specifically for logging facilities. You want to use mode "w+" (read/write) and don't worry, it won't destroy your ouput file like the plain old "w"-mode. > I would appreciate any advice or help to solve this problem. -- Christopher Curtis - http://www.ee.fit.edu/users/ccurtis Florida Institute of Technology - System Administrator, Programmer Melbourne, Florida USA - http://www.lp.org/