I have experienced some mysterious problems when trying to write something into a file.
The output file is created by fopen in the beginning of the program. The idea is at the end of the run I want to write some data into the file, using fprintf.
1 If I write something (e.g. "Hello world \n") into the output file at the beginning of my program, everything is fine. At the end of the program the data I really want is written into the output file (after the "Hello world\n" statement).
2 If I don't write any statement at the beginning of the run, the progran crashes when it is time to write data into the file. A segmentation fault message is generated, and the output file remains empty.
Can anyone explain such mysterious behavior?