binary/ bits representation of a character flushed into a text file

This is a discussion on binary/ bits representation of a character flushed into a text file within the C++ Programming forums, part of the General Programming Boards category; When a buffer is flushed into a textfile,does the (binary/bits of the character in the txt file correspond to the ...

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    118

    binary/ bits representation of a character flushed into a text file

    When a buffer is flushed into a textfile,does the (binary/bits of the character in the txt file correspond to the bits of the flushed buffer.Lets assume the flushed bufffer is an unsigned char.

    e.g
    Code:
    ofstream f;
    unsigned char a;
    f.open("testing.txt")
     a='129'
     f<<a;
    f.close;

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,625
    Firstly, the value of '129' is implementation defined( three characters ).

    About your question, yes when binary data is written to a file there( usually ) represent the data from which they came, they're not "translated". That's why if you write a 32-bit integer with binary mode in a file and you later open the file, you see 4 strange characters.
    Devoted my life to programming...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. character representation in C
    By firstoption in forum C Programming
    Replies: 5
    Last Post: 12-05-2011, 12:56 PM
  2. char to bits representation
    By bangesh in forum C Programming
    Replies: 2
    Last Post: 03-15-2010, 07:40 PM
  3. Replies: 3
    Last Post: 11-25-2006, 03:14 PM
  4. Writing binary data to a file (bits).
    By OOPboredom in forum C Programming
    Replies: 2
    Last Post: 04-05-2004, 03:53 PM
  5. copy some bits into a 8 bits binary number
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 05-29-2002, 10:54 AM

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