From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 26617 invoked from network); 27 Apr 1998 00:59:35 -0000 Received: from ip2.net20483142.cr.sk.ca (HELO cabler.cableregina.com) (204.83.142.2) by mail2.redhat.com with SMTP; 27 Apr 1998 00:59:35 -0000 Received: from [24.72.3.110] by cabler.cableregina.com (SMTPD32-4.0) id A68416330318; Sun, 26 Apr 1998 18:59:32 -0700 Received: (from laz@localhost) by walleye.gonefishing.sk.ca (8.8.5/8.8.5) id SAA02075 for axp-list@redhat.com; Sun, 26 Apr 1998 18:56:30 -0600 Date: Sun, 26 Apr 1998 18:56:30 -0600 From: Larry Zimmerman Message-Id: <199804270056.SAA02075@walleye.gonefishing.sk.ca> To: axp-list@redhat.com Subject: Problem with binary file I/O I am converting a program from FORTRAN to C that reads a set of keyed input records from an ASCII file, and writes the data to a binary file. The keys may appear on more than one record with different types of data. My program stores the key and data in a structure and writes the structure to a binary file. The program keeps a list of known keys and their record number in the binary file. When I use the "high-level" file I/O functions, the program fails. When I use the "low-level" functions, the program works. I posted this problem to a couple of comp.os.linux.? newsgroups, but got no response - maybe no-one else has this problem, or maybe no-one believes me, or maybe no-one knows how to fix it! I wrote a test program to demonstrate the problem - see link below - and have discovered the following: The record numbers used by the program are correct. The file position (used by fseek) is correct. I also used ftell to verify the file position. Even though the program reports the correct file position for writing, it appends the data to the end of the file (?????). I have a web page with more details and the sample program at: http://walleye.gonefishing.sk.ca/laz/rdwr/problem.html I would appreciate any advice or help to solve this problem. Larry Z.