I am experimenting with the following code. It outputs a in hex, sa in decimal. I cant figure out how to “Upper Case” the value for a as “F”.
#include <stdio.h>
Void foo()
{
int a = 10;
static int sa = 10;
a += 5;
sa += 5;
printf("a = %x, sa = %d\n", a, sa);
}
int main()
{
int i;
for (i = 0; i < 10; ++i)
foo();
}
To convert integers to hexadecimal format in uppercase, use
%X. Note that the0xprefix output for non zero values for%#xwill also be uppercased with%#XSimilarly, you can use
%E,%F,%Gand%Ato convert floating point numbers using uppercase letters instead of lowercase.C23 added binary conversion with
%b, and if used with the#modifierprintfoutputs a0bprefix for non zero values.%#Bcan be used to produce a0Bprefix instead.