How do I print a hexa in c through the printf?

Asked

Viewed 2,936 times

0

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

  • Use the editor’s '{}' to format your code. This makes it more organized.

1 answer

1

To print a HEX in C we have the options:

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

You can also specify how many boxes either in print using %4x for 4 houses for example or %04x to complete the numbers on the left with zeros.

See on ideone.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.