Is there a way to read bits for bits from a file and then write bit for bit to a file in c++?
This is a discussion on reading/writing bits from/to a file within the C++ Programming forums, part of the General Programming Boards category; Is there a way to read bits for bits from a file and then write bit for bit to a ...
Is there a way to read bits for bits from a file and then write bit for bit to a file in c++?
No. All reads and writes operate, at the smallest, on bytes. In fact, by the very definition of a byte, it is the smallest addressible unit of storage.
Every variable, every read and write, etc. operate on integer numbers of bytes.
To elaborate on what Cat said, you have to read it out as a byte (or more), but you can still access the individual bits of the variables you read out of the file by using bit shifting.
Away.
Ok, tnx.