[I have removed "comp.lang" and "comp.std" from the Newsgroups: line
since they appear to be invalid. If not, sorry.]
[...]
Quote:
>2) Some "numbers" will stop fgetc or scanf cold. i.e. The character ctrl-Z
>is used as end of file on many machines, and fgetc/scanf will honor this.
#1. Not if you fopen in binary mode with an ANSI compiler.
#2. Don't ever use scanf!!!
Quote:
>The only routines you should be using for a "binary" file are fread and
>fwrite, even if you are writing the file one byte at a time.
This is not true. They must behave as if getc and putc were used,
and the macros may well be much faster.
There may be
Quote:
>other "characters" beyond the ctrl-Z (decimal 26) that will get you into
>trouble when you try to read them (or write them) with the character
>routines.
Again, don't fopen in text mode. But make sure that when you get a
character you put it in an int, not a char, because otherwise
EOF (typically -1) will compare equal to one of the binary char's.
Quote:
>If you want a truly portable file, convert the numbers to text and write a
>completely display-able file.
Ah, some correct advice. (Also makes debugging incredibly easier,
take my word for it!)
Cheers,
Stan.
--
HELP! I'M BEING HELD PRISONER IN A .SIGNATURE FACTORY!