I would I read a byte in a file and interpret it as hex?
So if I put FF in a file using a hex editor, and then make my program open it and read it as FF?
C program reading files?
#include %26lt;stdio.h%26gt;
#define NSize 100
main ()
{
FILE *fPtr = fopen("your file name here" , "r");
unsigned char inBytes[NSize ]; // dimension or allocate to the size you want
fread(inBytes, 1, NSize, fPtr ); //read bytes out of the file
fclose(fPtr);
printf("%0x\n", (int)inBytes[0]);print the first byte in hex
}
Reply:use fscanf("%x",..);
jj
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment