goretti
asked on
unsigned char to String
HI
I want to combine the unsigned char into a string array, how can I do that?
void outputMAC(unsigned char MAC[])
{
printf("Your MAC Address Is: %02X-%02X-%02X-%02X-%02X-% 02X", MAC[0], MAC[1], MAC[2], MAC[3], MAC[4], MAC[5]);
// finalmac=MAC[0]+MAC[1]+MAC [2]+MAC[3] +MAC[4]+MA C[5];
}
MAC[0]=00 in HEX
MAC[1]=04 in HEX
MAC[2]=75 in HEX
MAC[2]=82 in HEX
MAC[2]=26 in HEX
MAC[2]=EA in HEX
how can I reformat them into array that store "0004758226EA" into arrary
because i need to perform xor with another array
a[0]=1
a[1]=6
a[2]=4
a[3]=A
etc...
0 0 0 4
1 6 4 A xor
---------------
Pls help
I want to combine the unsigned char into a string array, how can I do that?
void outputMAC(unsigned char MAC[])
{
printf("Your MAC Address Is: %02X-%02X-%02X-%02X-%02X-%
// finalmac=MAC[0]+MAC[1]+MAC
}
MAC[0]=00 in HEX
MAC[1]=04 in HEX
MAC[2]=75 in HEX
MAC[2]=82 in HEX
MAC[2]=26 in HEX
MAC[2]=EA in HEX
how can I reformat them into array that store "0004758226EA" into arrary
because i need to perform xor with another array
a[0]=1
a[1]=6
a[2]=4
a[3]=A
etc...
0 0 0 4
1 6 4 A xor
---------------
Pls help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For the exact problem you adress there, I think:
sprintf(TheResult, "%01X%02X", (MAC[4] & 0xF)^rgValue[9], MAC[5]^(rgValue[10] << 4 + rgValue[11]));
is quite efficient, but maybe not so easy to follow at first glance...