Home > C, Linux

C语言的基本数据类型

整型:
char类型,1 byte。
标准ASCII表的范围:0-127.
unsigned char 范围:0-255
signed char 范围:-128-127
除了char 还有short int (简称short),int,long int(简称long),long long int(简称 long long),这些类型都可以加上signed或unsigned关键字表示有符号或无符号数。
浮点型:
float,double,long double。
可以通过以下c程序获得某平台某个数据类型的长度。

#include 
int main()
{
        printf("sizof char %d\n",sizeof(char));
        printf("sizeof  unsigned char= %d\n",sizeof(unsigned char));
        printf("sizeof  signed char= %d\n",sizeof(signed char));
        printf("sizof int %d\n",sizeof(int));
        printf("sizeof  unsigned int = %d\n",sizeof(unsigned int));
        printf("sizeof  unsigned short int= %d\n",sizeof(unsigned short int));
        printf("sizeof  short= %d\n",sizeof(short));
        printf("sizeof  long = %d\n",sizeof(long));
        printf("sizeof  long= %d\n",sizeof(long long));
        printf("sizeof  float= %d\n",sizeof(float));
        printf("sizeof double= %d\n",sizeof(double));
        printf("sizeof long double= %d\n",sizeof(long double));
}

请选择你看完该文章的感受:

不错 超赞 无聊 扯淡 不解 路过

随机文章:

发表评论