Link to home
Start Free TrialLog in
Avatar of goretti
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]+MAC[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

ASKER CERTIFIED SOLUTION
Avatar of Knut Hunstad
Knut Hunstad
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I just realized this question is a continuation of https://www.experts-exchange.com/questions/21853382/XOR-with-MAC-and-windows-registry.html, would have been nice if you pointed that out in your question :-)

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...