Hi! Well, I don't quite get your question. "How do you read the "real" values from hex code?" What real values? A hex number is a "real" value...
I guess what you meant was how to transcribe a hex value to a dec value. I'm not going into detail on that one, because I think that you should know this if you want to mess with memory contents. The hexadecimal number system ranges from 0 to F (meaning 15dec). Normally you deal with "number pairs" like b4, so the maximum value could be FF, or 255dec. In the case of B4 this means -> b=11dec, 11*16+4 = 180dec. If you want to know what character this resembles -> Grab an ASCII chart and look it up.
To "convert" values you can use sscanf.
#include <stdio.h>
int main(int argc, char* argv[])
{
long dec;
if(argc != 2)
{
printf("Usage: %s HEXVALUE\n",argv[0]);
exit(1);
}
sscanf(argv[1], "%x", &dec);
printf("Dec: %ld", dec);
return 0;
}
upCASE ----------------------------------- If it was hard to write, it should be hard to read!- Do. Or do not. There is no try! |