[Dev-C++] Simple question about reading files
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Alain P. <ala...@ge...> - 2004-04-20 06:16:37
|
Hi all,
I have to read a file that contains binary data, including some 0xff, 0x00 and 0x1A. I tried fread and fgetc. But when the 0x1A is read, this doesn't work. For example, if you write a loop to read a file containing
0x41 0x1A 0x42 0x43 ....
The loop is like :
while (!EOF) {
fread(&mycharbuffer, 1, 1, myfile);
}
First read character is 0x41
Second read character is 0x41 ! Because the 0x1A can't be read by fread, mycharbuffer contains the previous value !!
How can I read a file so that every byte can be any value between 0x00 and 0xFF in this file ???
Thank you for any advice.
|