Thread: Writing to a Binary File

  1. #1
    Registered User
    Join Date
    Mar 2004

    Writing to a Binary File

    How do you write to a Binary File, compared to an Ascii file?

  2. #2
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    well open the file in binary mode


    where WB means Write mode and Binary mode... (if i am right)

  3. #3
    Ultraviolence Connoisseur
    Join Date
    Mar 2004
    using fseek.

  4. #4
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    More specifically wb means to open the file in binary mode with permission to write and place the file pointer at the beginning of the file.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Quote Originally Posted by nonpuz
    using fseek.
    What are you talking about? Fseek doesn't write anything, binary or text. You write the same way for both file types. However, the end result may vary depending on how you open it. I say may, because on unix systems, there is no difference between binary and ascii according to the man pages:
    The mode string can also include the letter ``b'' either
    as a third character or as a character between the charac-
    ters in any of the two-character strings described above.
    This is strictly for compatibility with ANSI C3.159-1989
    (``ANSI C'') and has no effect; the ``b'' is ignored.
    So it is possible that fseek behaves differently when you use it, depending on mode.

    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. Replies: 2
    Last Post: 05-09-2008, 07:27 AM
  3. Replies: 1
    Last Post: 12-10-2005, 11:25 AM
  4. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM