To be a better coder
分类: LINUX
2019-03-20 11:19:41
(1) printf(“%d”,sizeof(‘A’));//输出4
分析:sizeof()是一个表达式,字符’A’由char类型提升到int,所以打印出是4(int的大小),而不是1(char的大小)。
(2)char a,b;
printf ( " the size of the result of a+b :%d " ,sizeof( a+b) ); //输出4
(3)char a;
printf ( "%d\n" ,sizeof(a)); //输出1unsigned char b = 1;
printf("%d", a > b);//输出0
(5)
int a = -1;
unsigned int b = 1;
printf("%d", a > b);//输出1
unsigned int b = -1;
printf("%d\n",a==b);//输出1
(7) char a = -1;
unsigned char b = 1;
printf("%d", a > b);//输出0
分析:整形提升,参看上一节分析。
(8) int a = -1;
unsigned char b = -1;
printf("%d\n", a < b);//输出是1