I have been looking for a way to write a binary file to store the user data. I found that is not hard at all but the way I’ve seen people doing it would be a complete waste of memory.
The problem is as follows: for instance, I want to store an int number from 0 to 255; I could just write an int to the binary file, that would take up 32 bits of memory, but reality is I just need 8.
How can I get a binary representation of that number and store it with exactly 8 bits to the file? (4 would be 00000100; 200 would be 11001000; etc, etc).
Thanks in advance