Print "A" represented in HEX (printf ("\ 0x41"))

How to do printf("\0x41"); draw the letter "A". I know what the \0end of a line means, but how to fight when I need to print the character represented in HEX?

+3
source share
2 answers

Drop the leading 0 in the hexadecimal character:

printf("\x41");

Numeric literals use a prefix 0x, characters use \x.

You can also add a translation string to make sure it is displayed:

printf("\x41\n");

You can also type one character:

printf("%c\n", 0x41);

or portable:

printf("%c\n", 'a');
+5
source

Try as follows:

printf("%c", 0x41);

0
source

All Articles