Re: confused abt file operations
- From: gordonb.xrqth@xxxxxxxxxxx (Gordon Burditt)
- Date: Tue, 30 Aug 2005 18:33:01 -0000
>If I open a binary file in text mode and use text functions to
>read it then will I be reading numbers as characters or actual
>values?
>What if I open a text file and read it using binary read functions.
The difference between a binary and text file on most implementations
is either (a) none at all, or (b) the line ending (\n vs. \r\n vs.
\n\r vs. something else). This doesn't rule out things like binary
line numbers and line lengths preceeding the line with no end-of-line
terminator, but these are very rare.
What is a "text function"? There is no such division ("fread and
fwrite are for binary, printf, fgets, fputs, scanf, etc. are for
text" is a myth).
The practical effect is likely that you will see stray \r characters
before or after \n characers if you read a text file as binary. If
you read a binary file as text, some of the \r characters might
vanish. You might see a binary file read as text somewhat shorter
than expected if the binary file contains a text "end of file
character" which is interpreted as such.
Gordon L. Burditt
.
- Follow-Ups:
- Re: confused abt file operations
- From: Peter "Shaggy" Haywood
- Re: confused abt file operations
- References:
- confused abt file operations
- From: siliconwafer
- confused abt file operations
- Prev by Date: Re: Style isn't always religious
- Next by Date: Re: while (1) vs. for ( ;; )
- Previous by thread: confused abt file operations
- Next by thread: Re: confused abt file operations
- Index(es):
Relevant Pages
|