Is this a good Idea?? 
Author Message
 Is this a good Idea??

[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!



Fri, 27 Mar 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. how good am I? Am I Good Enough????

2. Is this a good Idea??

3. Sorting multi column ListView -code-Any better ideas?

4. link libraries to libraries a good idea?

5. Help with ideas, best ways etc...

6. Vivianne has a good idea

7. Is this a good idea?

8. Is this a good idea? (cont)

9. Bad trick or good idea?

10. Good program ideas?

11. Is this a good Idea??

 

 
Powered by phpBB® Forum Software