0

I am currently writing a little applet to modify files in a certain way. However, I am noticing wildly strange behaviour. I have an output file that is fopen'd in "a+" mode. If the file did not exist and was created, the resulting output is total garbage (however, it exhibits the expected filesize). If the file already existed, the whole program crashes on the matching call to fclose for the same file. I am using plain old standard fprintf calls to output to the file.

Can anyone help me figure out what is causing this?

Edited by pritaeas: Moved.

3
Contributors
2
Replies
14
Views
3 Years
Discussion Span
Last Post by rubberman
0

What operating system/version are you using. According to the Linux man page for fopen, the usage of "a+" is this:

       a+     Open for reading and appending (writing at end of file).  The file is created if it does not exist.  The initial  file position for reading is at the beginning of the file, but output is always appended to the end of the file.

In any case, I have NEVER seen a crash on any Linux or Unix system using this. Windows? Don't know about Win7, but I never had any problems on XP and earlier versions of Windows NT.

Edited by rubberman

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.