Thread: i have a question

  1. #1
    Registered User
    Join Date
    Dec 2005

    i have a question

    what are two differences between text file and binary files

  2. #2
    Registered User
    Join Date
    Dec 2005
    my knowledge in c programming is very limited. im trying to increase my knowledge

  3. #3
    Join Date
    Aug 2002
    Tucson, Arizona

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Depending on your OS, not a damn thing. Otherwise, usually just how they handle the writing of a new line.

    Hope is the first step on the road to disappointment.

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Unix is a system that treats the modes the same way. Windows/DOS is not.

    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:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Hannover, Germany
    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.

    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM