Reading a binary file bit by bit

后端 未结 6 1959
终归单人心
终归单人心 2020-12-16 19:35

I know the function below:

size_t fread(void *ptr, size_t size_of_elements, size_t number_of_elements, FILE *a_file);

It only reads byte by

6条回答
  •  甜味超标
    2020-12-16 20:00

    Adding to the first comment, you can try reading one byte at a time (declare a char variable and write there), and then use the bitwise operators >> and << to read bit by bit. Read more here: http://www.cprogramming.com/tutorial/bitwise_operators.html

提交回复
热议问题