Using the # flag with conversion specifiers o, x, X and any floating-point specifier : printf format « printf scanf « C Tutorial






#include <stdio.h>

int main()
{ 
   int c = 1234; 
   double p = 1234.0;
   
   printf( "%#o\n", c );
   printf( "%#x\n", c );
   printf( "%#X\n", c );
   printf( "\n%g\n", p );
   printf( "%#g\n", p );

   return 0;

}
02322
0x4d2
0X4D2

1234
1234.00








4.19.printf format
4.19.1.Characters in the format control string
4.19.2.Using the # flag with conversion specifiers o, x, X and any floating-point specifier