MoonchildHK
Programmer
HI All,
I have been trying to get this right for ages, and have ended up with about 10 lines of code for what I;m sure can be done in 1 statement!
I have a block of data stored in the registry. The block is binary: Ax Bx Cx Dx Ex Fx Gx Hx (8 Bytes)
Here is my problem: ExFx is an Integer I need to extract from the data block. I have tried using sscanf to get the data but can't get it right.. when I look at the data using RegEdit the bytes I need look like this:
93 b8 (For this example)
Now, I have already copied the data from the registry into memory pointed to by a pointer (char *data).
When I do something like this :
int a = *(data + 4)
.. I should get 147, but I end up with -109
My plan was to do
int a = *(data + 4)
int b = *(data + 5)
int number = (a*255) + b;
But now I have a horrible piece of code (where I search for "FFFFFF" in a string respresentation of the hex value and then replace it with "000000" to make it non-negative.
Any ideas would be most welcome
Thanks in Advance
I have been trying to get this right for ages, and have ended up with about 10 lines of code for what I;m sure can be done in 1 statement!
I have a block of data stored in the registry. The block is binary: Ax Bx Cx Dx Ex Fx Gx Hx (8 Bytes)
Here is my problem: ExFx is an Integer I need to extract from the data block. I have tried using sscanf to get the data but can't get it right.. when I look at the data using RegEdit the bytes I need look like this:
93 b8 (For this example)
Now, I have already copied the data from the registry into memory pointed to by a pointer (char *data).
When I do something like this :
int a = *(data + 4)
.. I should get 147, but I end up with -109
My plan was to do
int a = *(data + 4)
int b = *(data + 5)
int number = (a*255) + b;
But now I have a horrible piece of code (where I search for "FFFFFF" in a string respresentation of the hex value and then replace it with "000000" to make it non-negative.
Any ideas would be most welcome
Thanks in Advance