Guidance指路人g.yi.org Guidance Forums / wxWidgets (wxWindows) in C++ / Hex Values
 最新 LeonAutoBackup
 Forum List • Thread List • Refresh • New Topic • Search • Previous • Next  1 1. Hex Values#3804Posted by: IceCreamFlavor 2004-04-11 14:38:07 How do you read the "real" values from hex code?For example, the hex value: b4 09 cd 21 b8 01 4c cdIf anyone can tell me how to get a single integer\character\whatever from that long string of seemingly random numbers, it would help me tremedously!______________________   /              \    IceCreamFlavor   \______________/______________________I'll schoot the ground, make you scared!I will chop your nuts off! 2. Re: Hex Values#3808Posted by: upCASE 2004-04-12 19:21:39 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 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! Forum List • Thread List • Refresh • New Topic • Search • Previous • Next  1