How do I print a hexa in C through printf?

/ / example
mascara=0xFF;
blue = COR1 & mascara; / / color a macro I used
printf ("%s \n", blue); / / doubt in bold

Author: Camila Santos, 2017-08-26

1 answers

To print a HEX in C we have the options:

  • %i prints the corresponding integer value.
  • %x prints the normal HEX value

You can also specify how many houses you want in print by using %4x for 4 houses for example or %04x to fill in the numbers on the left with zeros.

See in ideone .

 1
Author: Gustavo Fragoso, 2017-08-26 20:20:19