i have a question

This is a discussion on i have a question within the C Programming forums, part of the General Programming Boards category; what are two differences between text file and binary files...

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    14

    i have a question

    what are two differences between text file and binary files

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

  3. #3
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,801
    Woop?

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    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.

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    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.

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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    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 Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21