(1 / 1)
Date: October 01, 1985 12:27
From: KIM::RAINS
To: @SYS$MAIL:ENGINEER
WARNING: A lesson which might be less painful for you if you learn it here: FILE *outfil; char c; /* output char */ int err; /* putc() result code */ . . . if ((err = putc(c, outfil)) == EOF) { perror(" Output error in putc() - disk full? "); return (ERROR); } . . . This will screw up on binary files when (c = 0xFF) is output, because putc() will return the sign extended argument, which will be EOF (-1) rather than 0xFF. You need to either check ferr(outfil) on EOF, or call putc(c & 0xFF, outfil) to suppress the sign extension. It ain't like getc()!! OLD NEWS: Also, since getc and putc() are #define macros on some systems (including UNIX), don't make calls like putc(*cp++, outfil), since the side effect will blow up in your face. Use fgetc() and fputc(), which make proper subroutine calls instead.
Oct 01, 1985