[plug] C, bad syntax etc.
Denis Brown
dsbrown at cyllene.uwa.edu.au
Tue Nov 19 09:39:43 WST 2002
Hello, John.
The following code works as the simplest case. @@@@
#include <stdio.h>
FILE *fptr;
main()
{
fptr = fopen ("myfile.txt", "a+");
fprintf (fptr, "hello\n");
fclose (fptr);
}
As Carl noted earlier, it would pay to take the fopen / fclose pair out of
your loop construct. That will avoid having to use "a" or "a+" in the
open statement; a simple "w" would then suffice, over writing any existing
output file or creating one if previously nonexistent.
As to why your fclose doesn't behave... anyone??? Corrupted library
maybe?
HTH,
Denis
@@@@ based on the recent perl sort "competition" for skinny code, I am
uneasy in stating absolutes anymore :-) If anyone has a simpler version
of the above, I'm all eyes.
Cheers.
More information about the plug
mailing list