I am writing a file encryption program for my senior project (don't worry we are encouraged to seek outside help). but i am having a problem that many files (such as .doc and .exe) use multiple null characters in their encoding. I need a way to tell the difference between a null and eof. any ideas?
Make sure the variable you are reading into (if done character by character) is of type int and not type char and you shouldn't have any problems.
Also open the file as a binary file.
I feel a little silly... but how do i input the file as binary as opposed to ascii???
Of course you can use other modes also, the b just means to open it in binary mode.
>I feel a little silly... but how do i input the file as binary as opposed to ascii???
Or you could use get() if you prefer reading it one char at a time.
I appreciate both of your help, i got it going.
There is some very good information in the Programing FAQ about using EOF.
EOF is NOT a null character at the end of the file like the null termination at the end of a C-style string. That's the way I misunderstood it until Hammer straightened me out! I thought that EOF only worked for ASCII files... WRONG!!!
The operating system knows where the end of the file is, and tells your program if EOF is true or false.