M
Martin Kleiner
Hi
I have an 8 byte array of hex characters, e.g.
['c','5','3','1','0','6','5','9'] and I wanna convert this
to an unsigned int, so that unsigned int i = 0xc5310659. I wonder if
in C there is an very easy way to do that?
One cumbersome way to do that would be:
unsigned int arrToInt = 0;
for(i=0; i<8; i++) {
arrToInt =(arrToInt<<8) | toIntVal(charBuffer);
}
int toIntVal(char c)
{
int value = 0;
switch (c)
{
case '0':
value = 0;
break;
case '1':
value = 1;
break;
....
default:
return val;
}
has someone an easier idea?
Thanks!
I have an 8 byte array of hex characters, e.g.
['c','5','3','1','0','6','5','9'] and I wanna convert this
to an unsigned int, so that unsigned int i = 0xc5310659. I wonder if
in C there is an very easy way to do that?
One cumbersome way to do that would be:
unsigned int arrToInt = 0;
for(i=0; i<8; i++) {
arrToInt =(arrToInt<<8) | toIntVal(charBuffer);
}
int toIntVal(char c)
{
int value = 0;
switch (c)
{
case '0':
value = 0;
break;
case '1':
value = 1;
break;
....
default:
return val;
}
has someone an easier idea?
Thanks!