// This program uses the printf and wprintf functions // to produce formatted output. #include int main( void ) { char byteChar = 't', *aString = "My computer"; wchar_t wideChar = L'm', *wideString = L"Unicode string"; int intCount = -8324; double floatPoint = 370.4432; printf("Size of char: %d byte.\n", sizeof(char)); printf("Size of wchar_t: %d byte.\n", sizeof(wchar_t)); printf("Size of int: %d byte.\n", sizeof(int)); printf("Size of double: %d byte.\n\n", sizeof(double)); // Display integers printf( "Sample of Integer %d format:\n" " Decimal: %d Justified: %.6d " "Unsigned: %u\n", intCount, intCount, intCount, intCount ); // Display decimals printf( "Sample of Decimal %d as:\n Hex: %Xh " "C hex: 0x%x Octal: %o\n", intCount, intCount, intCount, intCount ); // Display in different radixes printf( "Digits 10 equal to:\n Hex: %i " "Octal: %i Decimal: %i\n", 0x10, 010, 10 ); // Display characters printf("Characters in field (1):\n" "%10c%5hc%5C%5lc\n", byteChar, byteChar, wideChar, wideChar); wprintf(L"Characters in field (2):\n" L"%10C%5hc%5c%5lc\n", byteChar, byteChar, wideChar, wideChar); // Display strings printf("Strings in field (1):\n%25s\n" "%25.4hs\n %S%25.3ls\n", aString, aString, wideString, wideString); wprintf(L"Strings in field (2):\n%25S\n" L"%25.4hs\n %s%25.3ls\n", aString, aString, wideString, wideString); // Display real numbers printf("Real numbers:\n %f %.2f %e %E\n",floatPoint, floatPoint, floatPoint, floatPoint ); // Display pointer printf( "\nMemory address as: %p\n", &intCount); return 0; }