hi all...
i have a small program that reads an image char by char in binary mode. so the output looks like :
<FF> 1
<D8> 2
<FF> 3
<E1> 4
^W 5
{ 6
E 7
x 8
i 9
f 10
^@ 11
^@ 12
M 13
M 14
^@ 15
* 16
........
i need to make sure that the first char - here above as <FF> - is always at the start of the file. sometimes it isn't. so i need to look for the <FF>. in order to find it i was told to look for 0xFF. but when i do the comparison as in (c == 0xFF ) is not doing it.
here is what i got:
Code:int main (int argc, char *argv []) { FILE * fhin = fopen (argv[1], "rb"); char c; int i = 1; while (fread (&c, 1, 1, fhin) ) { if ( c == 0xFF) printf("%s\t", "moo"); printf("%c\t%d\n", c, i++); } fclose (fhin); return (0); }
what would be the correct way?
thanks..



LinkBack URL
About LinkBacks



