E
Eik
Hey,
I got a serieus problem with reading a 26-byte (0x1A, 032, b00011010:
SUB [Substitute]) from a file.
Take this example:
---BEGIN PROGRAM---
#include <stdio.h>
main () {
int i;
unsigned char c;
FILE *fp;
fp = fopen ("chars.txt", "r");
for (i = 0; i < 256; i++) {
c = getc (fp);
printf ("%3d|", c);
}
}
---END PROGRAM---
The file chars.txt contains 256 bytes -> byte values: 0, 1, 2, ...,
253, 254, 255
When I run the program I get this:
0| 1| 2| ... 24| 25|255|255|255| ... etc. Til 'i' reaches 256 and
the program stops shitting '255' (EOF's) on my screen
What is wrong with the 26-byte?!?
When I remove the 26-byte from chars.txt, I get this:
0| 1| 2| ... 24| 25| 27| 28| ... 253|254|255|255|
Why is the 26-byte ruining my program? How should I change my program?
THX
Ps. I'm using Windows XP, and the C-compiler Miracle C
Ohhh... and does anybody know how you can get the size of an file
without checking where the EOF byte is (because in binairy file's
there are more EOF's)
I got a serieus problem with reading a 26-byte (0x1A, 032, b00011010:
SUB [Substitute]) from a file.
Take this example:
---BEGIN PROGRAM---
#include <stdio.h>
main () {
int i;
unsigned char c;
FILE *fp;
fp = fopen ("chars.txt", "r");
for (i = 0; i < 256; i++) {
c = getc (fp);
printf ("%3d|", c);
}
}
---END PROGRAM---
The file chars.txt contains 256 bytes -> byte values: 0, 1, 2, ...,
253, 254, 255
When I run the program I get this:
0| 1| 2| ... 24| 25|255|255|255| ... etc. Til 'i' reaches 256 and
the program stops shitting '255' (EOF's) on my screen
What is wrong with the 26-byte?!?
When I remove the 26-byte from chars.txt, I get this:
0| 1| 2| ... 24| 25| 27| 28| ... 253|254|255|255|
Why is the 26-byte ruining my program? How should I change my program?
THX
Ps. I'm using Windows XP, and the C-compiler Miracle C
Ohhh... and does anybody know how you can get the size of an file
without checking where the EOF byte is (because in binairy file's
there are more EOF's)