g3k0
February 16th, 2008, 09:38 PM
Hey, I just want to read a byte from a file. Not as ascii. How do I do this in c++. I tried using fscanf but for some reason the variable becomes a gigantic number. I know there is a hex value of 32 right where I am reading. I fread() it and get a 2 because 32 is ascii. But I want to get the decimal equivalent of 32 hex instead.
string MyStr;
int YAY;
char theC[6];
FILE * cdRm = fopen ( "/dev/hdb", "r" );
fseek(cdRm, 16*sectorSize+dateVolCreateOff,SEEK_SET);
int n = fscanf ( cdRm, "%d", &YAY );
sprintf(theC,"%d",YAY);
fclose(cdRm);
MyStr = theC;
string MyStr;
int YAY;
char theC[6];
FILE * cdRm = fopen ( "/dev/hdb", "r" );
fseek(cdRm, 16*sectorSize+dateVolCreateOff,SEEK_SET);
int n = fscanf ( cdRm, "%d", &YAY );
sprintf(theC,"%d",YAY);
fclose(cdRm);
MyStr = theC;