【C语言】测试系统各数据类型大小代码

测试各系统不同数据类型大小代码

 一、相关基础知识                                                 

不同环境下各数据类型大小可能不相等,(某些环境下,类型带下可以选择)故测了就知道!

 二、具体内容                                                     

 三、分析总结                                                     

 四、实例测试                           

   

#include<stdio.h>

int main(void)
{
    signed int a1;
    unsigned int a2;
    signed long int a3;
    unsigned long int a4;
    signed long long int a5;
    unsigned long long int a6;
    signed short int a7;
    unsigned short int a8;
    
    float a9;
    double a10;
    long double a11;

    char a12;

    _Bool a13;
    
    printf("各种数据类型所占字节数(1字节8个bit位)\n\n");
    printf("signed int              有符号整数:%d字节\n", sizeof(a1));
    printf("unsigned int            无符号整数:%d字节\n\n", sizeof(a2));
    printf("signed long int         有符号长整数:%d字节\n", sizeof(a3));
    printf("unsigned long int       无符号长整数:%d字节\n\n", sizeof(a4));
    printf("signed long long int    有符号长长整数:%d字节\n", sizeof(a5));
    printf("unsigned long long int  无符号长长整数:%d字节\n\n", sizeof(a6));
    printf("signed short int        有符号短整数:%d字节\n", sizeof(a7));
    printf("unsigned short int      无符号短整数:%d字节\n\n", sizeof(a8));

    printf("float                   单精度:%d字节\n", sizeof(a9));
    printf("double                  双精度:%d字节\n", sizeof(a10));
    printf("long double             长双精度:%d字节\n\n", sizeof(a11));

    printf("char                    字符型:%d字节\n\n", sizeof(a12));

    printf("_Bool                   布尔型:%d字节\n", sizeof(a13));

    getchar();
    return 0;
}

 

                     

posted @ 2015-11-30 23:58  Ahair  阅读(646)  评论(0编辑  收藏  举报