Reading/writing a file containing multiple NULLs into buffer
Hi all,
I am trying to read a binary file containing multiple NULL characters into a char buffer. I was hoping to use fseek() and ftell() to read the size of the file, and use the reported filesize to allocate memory to the buffer (to contain the full size of the file, of course). But since fseek() terminates on the first occurrence of a NULL byte, I'm only able to read the first little segment of my file.
What would be the best way of reading in the ENTIRE file into memory, NULLs and all, until EOF?