可能重复:
Why are C character literals ints instead of chars?为什么sizeof('a')在C中是4?
#include<stdio.h>
int main(void)
{
char b = 'c';
printf("here size is %zu\n",sizeof('a'));
printf("here size is %zu",sizeof(b));
}
这里输出(见现场演示here)
here size is 4
here size is 1
我没有得到为什么sizeof('a')
是4?
参见[为什么是C字符文字整数,而不是字符?(http://stackoverflow.com/questions/433895/why-are-c-字符文字,整数,INSTEAD-OF-字符) – 2011-12-28 10:46:44