From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,3ecc95b3e37be78d,start X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1993-05-10 04:49:51 PST Path: gmd.de!newsserver.jvnc.net!netnews.upenn.edu!news.cc.swarthmore.edu!mac2.martin1.swarthmore.edu!user From: ajasent1@cc.swarthmore.edu (amal jasentuliyana) Newsgroups: comp.sys.dec Subject: Ultrix file I/O using C Message-ID: Date: 10 May 93 10:52:16 GMT Sender: news@cc.swarthmore.edu (USENET News System) Followup-To: comp.sys.dec Organization: swarthmore college Nntp-Posting-Host: mac2.martin1.swarthmore.edu I'm having trouble writing files using C on a DEC machine running Ultrix. The same code runs fine on a macintosh, so it has something to do with Ultrix I/O. In short, my program generates output ascii files of about 30-40K. The program has a main loop that allows a user to vary parameters & generate ouput files. As long as the program is user-driven, things work fine. Since I dont want to sit around all night running the program, I wrote a routine to vary the parameters automatically and call the main loop, changing the output filename (and file pointer) each time. This works fine on the macintosh. On the DEC however, although the output files are generated, only the first file contains all the info it should. In successive files, all entries after a two-line header are zeros!! The text of the headers is fine. I even tried piping an input file to the program that exactly mimics what the user input would be for doing successive runs. Same problem. My hunch is that it has something to do with timing. Successive files may be being opened a few instructions after the pervious one was closed. Since these are large files, if there is some sort of buffer that writes 'em to disk, things may get screwy. All the same, why do the headers comeout fine? When I step through the program using a debugger, the second output file to be generated is fine at first. Howevever, once I let the program continue to its end (ie at its own pace) the file gets changed to zeros!! I'm using comands like fopen("file","w"), fprintf & fclose to generate the files. I will be very gratefull for any suggestions anyone has. Please use E-mail for replies.. Thanks amal.