This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

char to hex value

Hello,
I have a little problem displaying a char to an hex value.

char t;
t = 0x01;
printf("%x",t);
This code outputs 100 where I expected to get 1... Am I doing something wrong ?

Parents
  • "Am I doing something wrong ?"

    As Neil says: yes - you are failing to read the manual

    This issue is specifically discussed in the manual.

    If you put your cursor on 'printf' in the uVision editor window, then press F1, it will bring up the library help for printf - which includes the descriptions of the format specifiers, and the notes about char and int.

Reply
  • "Am I doing something wrong ?"

    As Neil says: yes - you are failing to read the manual

    This issue is specifically discussed in the manual.

    If you put your cursor on 'printf' in the uVision editor window, then press F1, it will bring up the library help for printf - which includes the descriptions of the format specifiers, and the notes about char and int.

Children