Reading/Writing Binary

This is a discussion on Reading/Writing Binary within the C++ Programming forums, part of the General Programming Boards category; How can I read and write a file in binary. I mean so when you read a text file or ...

  1. #1
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342

    Question Reading/Writing Binary

    How can I read and write a file in binary.
    I mean so when you read a text file or a
    driver you really see the 1s and 0s. Then
    you can save it like the same way, unlike
    text editors that will save it in a text
    format instead of what ever formate you
    really have it in.

    Thanks, August.

  2. #2
    Me pwn you.
    Join Date
    Feb 2006
    Location
    At my computer or in my bed.
    Posts
    46
    I don't know, however I do know that at 4:57 PM Today you were modifying your
    profile...

  3. #3
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    Here's a lil example

    Code:
    #include <fstream>
    using namespace std;
    int main()
    {
    	int example = 7;
    	ofstream out;
    	out.open("File.dat", ios::binary);
    	out.write(reinterpret_cast<char *>(&example), sizeof(example));
            out.close();
    }

  4. #4
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Quote Originally Posted by Dagger
    I don't know, however I do know that at 4:57 PM Today you were modifying your
    profile...
    I did that once. I forget who it was so I will call
    this user X. I saw that he was replying to this
    one thread, so I replyed to and it said: "X will
    now reply...". And then X finished typeing his
    long relpy, then replyed.

  5. #5
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Why not try a hex editor? Hex to binary conversion is extremely easy (you can just memorize 0-F in binary and then convert any number)

    Or heck, even try searching for "binary editor" maybe one exists (although I'm sure it would be less useful than a hex editor)
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 0
    Last Post: 11-04-2006, 10:07 AM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. Tutorial review
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-22-2004, 08:40 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM
  5. Reading/Writing in Binary
    By kuphryn in forum C++ Programming
    Replies: 4
    Last Post: 12-11-2001, 09:32 PM

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