What do you mean for example Keith? I know for portability to use "rb"
and "wb" but is there even more distinction you say from binary and text
files?
fseek() and ftell() have some weirdness with files opened in text mode on
platforms where text and binary modes differ. E.g. for Windows:
http://msdn.microsoft.com/en-us/library/75yw9bf3(v=vs.71).aspx
For streams opened in text mode, fseek has limited use, because
carriage return–linefeed translations can cause fseek to produce
unexpected results. The only fseek operations guaranteed to work on
streams opened in text mode are:
Seeking with an offset of 0 relative to any of the origin values.
Seeking from the beginning of the file with an offset value
returned from a call to ftell.
Also in text mode, CTRL+Z is interpreted as an end-of-file character
on input. In files opened for reading/writing, fopen and all related
routines check for a CTRL+Z at the end of the file and remove it if
possible. This is done because using fseek and ftell to move within a
file that ends with a CTRL+Z may cause fseek to behave improperly near
the end of the file.
My system with a copy of the C99 standard isn't to hand, but I'm fairly
sure that the standard says something similar, i.e. that fseek/ftell have
well-defined behaviour when used on binary streams but a large amount of
undefined behaviour when used on text streams.
I think Unix treats everything like a text file.
Unix uses a bare LF ('\n') as its EOL indicator and doesn't have an EOF
indicator, so there's no distinction between text and binary files on Unix
(i.e. there's no difference between "r" and "rb", etc).