HI, I'm a newbie in C++. I"m writing a program to control my zigbee device.
I have a problem in displaying the hex value.
void ParseMessage(PACKET_HEADER packet)
{
unsigned int command = (unsigned int)packet.packet[1];
command = 0x100 * command + (unsigned int)packet.packet[2];
for (int i = 0; i < MSG_TOTAL; i++)
{
if(MessageArray[i].Command == command)
{
EnterCriticalSection(&crs);
memcpy(MessageArray[i].packet,&packet.packet[3],packet.packet[0]);
// Command type 0x4687 is ZB_RECEIVE_DATA
if(command == 0x6606)
{
cout << "RX: " << MessageArray[i].packet[4] << endl;
the value for the packet (i set the packet as an array) is display like this when i check the array during debugging.
[0x0]= 0x09 '[]'
[0x1]= 0x66 'f'
[0x2]= 0x06 '[]'
[0x3]= 0x01 '[]'
[0x4]= 0x82 ','
[0x5]= 0xff 'y'
[0x6]= 0xff 'y'
[0x7]= 0xff 'y'
[0x8]= 0xff 'y'
[0x9]= 0xff 'y'
[0xa]= 0xff 'y'
[0xb]= 0xff 'y'
[0xc]= 0x00
the output of this when the cout is execute is symbol. I want the output will be in hex as listed in the array, not the symbol.
I want it to be 0x82.
How I can make it right?
I couldn't understand the full post... perhaps it might be better to use printf. They have actual special characters that are for hexadecimal numbers... printf("The hexadecimal number is 0x%x\n", hexnumvar);