what are two differences between text file and binary files
what are two differences between text file and binary files
my knowledge in c programming is very limited. im trying to increase my knowledge
Depending on your OS, not a damn thing. Otherwise, usually just how they handle the writing of a new line.
Quzah.
Hope is the first step on the road to disappointment.
Unix is a system that treats the modes the same way. Windows/DOS is not.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
To your computer there is no difference between binary and text files. A file is a collection of bytes ( numbers between 0 and 255 ).
Files are called "text" when all bytes in that file can be interpreted as letters and accordingly form a coherent text that can be read in an editor. Files are called binary, when the information consists in parts or completely of data that cannot be interpreted as text. If you open such a file in an editor, it will only show gibberish.
The difference in binary and text mode in C/C++ is the line feed character(s). Each system has it's own way of marking the end of lines in text files. On Windows it's 2 characters ( \r\n ) on Unix it's only one ( \n ). If you open a file in binary mode, you will read and write it, as it is. No translation will take place. If you open a file in text mode, the system will interpret your input/output and add missing characters. It will replace a single \n with \r\n when writing to a Windows system and it will replace a \r\n with a single \n when you read it. In other words, in text mode, you always have a \n as line terminator in your programs, while on disk, it's system specific. The specifics are added behind your back in text mode.
hth
-nv
She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."
When in doubt, read the FAQ.
Then ask a smart question.