Writing a stream of 9 bit values as bytes to a file in C
问题 I have an array with integer values from 0-511 (9 bits max). I am trying to write this to a file with fwrite . For Example, with the array: [257, 258, 259] Which is 100000001, 100000010, 100000011 I am trying to write 100000001100000010100000011 + extra padding of 0s to the file But since fwrite limits writes to 1 byte at a time, I am not sure how to go about doing this. I am new to bitwise operations and am not how to separate out the individual bytes. 回答1: You need a bit buffer. Since you