Thread: File I/O

  1. #1
    Deprecated Dae's Avatar
    Join Date
    Oct 2004

    File I/O

    I noticed when doing FILE* I/O in C the file comes out in gibberish, say when outputting a struct. However when doing I/O in C++ you usually output ASCII text, is it possible to output like C does it, and what is C doing anyway? is it outputting part of an exe or just non-ASCII?

    If its outputting part of an exe, thatd be cool. I wonder which method is used most, like those games that output .bin's and read from them. Do they output values and input them, or is an actual part of code being sent to the program (like C assumingly).

    Excuse my ignorance, thanks
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  2. #2
    The question is fairly unanswerable in a direct sense: Any program written with file I/O can either write to the file in binary or ASCII format. Writting in binary format would create a "garbage looking" file, and writting out in ASCII format will produce something you may recognise. Really though, it works the same.

    I'm not sure what you mean by "outputting part of an exe". Theres no reason an app couldn't, but theres very very few reasons it would. I assume you're refering to the binary output which will cause any data (be it a bitmap or an executable) to appear simular to the human eye when opened in a text editor.

    Chances are the reasons you find a difference between C and C++ file I/O is merely the examples you are using. Both C and C++ have libraries for file I/O which can all very easily write in either binary or text formats.
    "There's always another way"
    -lightatdawn (

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  3. 2 questions surrounding an I/O file
    By Guti14 in forum C Programming
    Replies: 2
    Last Post: 08-30-2004, 11:21 PM
  4. File I/O problems!!! Help!!!
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 05-17-2002, 08:09 PM
  5. advice on file i/o
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-29-2001, 05:56 AM