Integer Output, width, alignment, padding
#define __STDC_WANT_LIB_EXT1__ 1 #include <stdio.h> int main(void) { int k = 678;//from w w w .ja v a 2 s. co m // Display formats as heading then display the values printf_s("%%d %%o %%x %%X\n"); printf_s("%d %o %x %X\n", k, k, k, k); printf_s("\n|%%8d |%%-8d |%%+8d |%%08d |%%-+8d |\n"); printf_s("|%8d |%-8d |%+8d |%08d |%-+8d |\n", k, k, k, k, k); return 0; }
The following code
printf_s("%d %o %x %X\n", k, k, k, k );
outputs decimal, octal, and two varieties of hexadecimal for the value 678, with the default width specification.