1. //* typesize.c -- 打印类型大小 */
    2. #include <stdio.h>
    3. int main(void)
    4. {
    5. /* C99为类型大小提供%zd转换说明 */
    6. printf("Type int has a size of %zd bytes.\n", sizeof(int)); //4
    7. printf("Type char has a size of %zd bytes.\n", sizeof(char)); //1
    8. printf("Type long has a size of %zd bytes.\n", sizeof(long)); //4
    9. printf("Type long long has a size of %zd bytes.\n",sizeof(long long)); //8
    10. printf("Type double has a size of %zd bytes.\n",sizeof(double)); //8
    11. printf("Type long double has a size of %zd bytes.\n",sizeof(long double));//16
    12. return 0;
    13. }