I am trying to write raw binary bits at a time to a file.
I have found an example that uses unsigned char ->https://stackoverflow.com/a/2666669/1541965
But the minimum size is 8 bit (because of the unsigned char 0 to 255).
Is there a way to write bits to a file in a more direct way?
Thanks.
You haven’t said what operating system you’re using. But generally the smallest unit you get to write to a file is one 8-bit byte. If you want to write individual bits, you’ll need to assemble them into bytes in your own code. I don’t know of any OS whose file IO facilities allow writing of individual bits.