I am trying to load 32-bit hexadecimal into char array.
#define NUC 0xA8051701
unsigned char debug_msg[100];
sprintf (debug_msg, "%08x", NUC);
But it is loading only "A805" that to as ASCII character instead of hexadecimal. Can any one suggest what could be the problem.
What I'm actually looking for is:
debug_msg[0]=0xA8
debug_msg[1]=0x05
debug_msg[2]=0x17
debug_msg[3]=0x01
Instead of the correct value, it is loading as below:
debug_msg[0]=0x30
debug_msg[1]=0x30
debug_msg[2]=0x30
debug_msg[3]=0x30
debug_msg[4]=0x61
debug_msg[5]=0x38
debug_msg[6]=0x30
debug_msg[7]=0x35
Effectively it is loading 0x0000a805 that to in ASCII.