#include int main(void) { short int i = 3; long int j = 3; wchar_t* wide_str = L"This is a wide string"; long double d = 3.1415926535; // width specification printf("%%7s: %7s, %%7s: %7s,\n", "abc", "123456" ); // the # and hexadecimal representation, x printf("%%#x: %#x\n", 120 ); printf("%%x: %x\n", 12 ); // the # and hexadecimal representation, X printf("%%#X: %#X\n", 120 ); printf("%%X: %X\n", 12 ); // the # and octal representation, o printf("%%#o: %#o\n", 120 ); printf("%%o: %o\n", 12 ); // the # and width for floating point printf("%%#2f: %#2f\n", 120.567 ); // the g and G conversion specifiers printf( "%%g: %g\n", 3.1415926 ); printf( "%%g: %g\n", 93000000.0 ); printf( "%%G: %G\n", 93000000.0 ); // width and precision printf("%%4f: %4f\n", 12.4321 ); printf( "%%8.5f: %8.5f\n", 1.234 ); printf("%%.1f: %4.1f\n", 12.4321 ); printf("%%.3f: %.3f\n", 12.4321 ); // precision for number printf( "%%.3f: %.3f\n%%.3g: %.3g\n%%.3f: %.3f\n%%.3g: %.3g\n", 100.2, 100.2, 3.1415926, 3.1415926 ); // precision for string printf( "%%.5s: %.5s\n", "abcdefg" ); // width and plus sign printf("%%07d: %07d\n", 102 ); printf("%+d\n", 102 ); // width and minus sign printf("%%-7d,%%-5d,: %-7d,%-5d,\n", 11, 22 ); // the #, width and hexadecimal printf("%%#010x: %#010x\n", 121 ); printf("%%#010X: %#010X\n", 121 ); // length/size modifier/specification printf( "%%hd: %hd\n", i ); printf( "%%ld: %ld\n", j ); printf( "%%ls: %ls\n", wide_str ); printf( "%%Lg: %Lg\n", d ); return 0; }