we have a text file containing binary values.
say, we have a file “file.txt”,it contains binary datat, say 11001010
the size of this file is 8 bytes.
but we want these 8 bytes to be read as bits i.e. 8 bits and thus make 8 bits into 1 byte. How can we do it?
we just know the procedure:
1. take a buffer and read individual value into buffer
2.if the buffer value reaches 8,make those 8 bits into a byte and write to a file.
thanks in advance.
The following code reads such a text file as you describe. If the file contains a number of binary digits that is not divisible by 8, the extraneous digits are discarded.