C語言數字類型長度

#include <stdio.h>
int main(void)
{
	int  a = 'A';
	short int b ='A';
	long int c ='A';
	char d = 'A';
	float e = 'A';
	double f = 'A';
	long double g ='A';
	unsigned h ='A';
	unsigned int i ='A';
	unsigned short j ='A';
	unsigned long k ='A';
	printf("int = %d\n",sizeof a);
	printf("short int = %d\n",sizeof b);
	printf("long int = %d\n",sizeof c);
	printf("char = %d\n",sizeof d);
	printf("float = %d\n",sizeof e);
	printf("double = %d\n",sizeof f);
	printf("long double = %d\n",sizeof g);
	printf("unsigned = %d\n",sizeof h);
	printf("unsigned int  = %d\n",sizeof i);
	printf("unsigned short = %d\n",sizeof j);
	printf("unsigned long = %d\n",sizeof k);
	
	return 0;
}
結果:

[root@localhost sourcecode]# gcc sizeof.c
[root@localhost sourcecode]# ./a.out
int = 4
short int = 2
long int = 4
char = 1
float = 4
double = 8
long double = 12
unsigned = 4
unsigned int  = 4
unsigned short = 2
unsigned long = 4


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章