PDA

View Full Version : writing bits



timmu
7th January 2013, 10:50
I need to make a file with 3 bits (not bytes) in it: 0,1,0

Note that the number of bits is not multiplicate of 4. I don't want to wait until the byte buffer gets full.

I was wondering if Qt has anything specifically for writing
bits into binary files?

Santosh Reddy
7th January 2013, 11:21
General Filed (storead/memory in general) will deal as byte as minimum unit of operation. So if you want to store just 3 bits, there is no other way by as to save the complete byte. There is nothing special Qt can do this case.

One byte is minimum you one write. This applies to both binay files/ text files, in fact binay/text is just to specify how read/write the file, at the core (OS -> Hard drive) every thing is written as binay data.