可能重複:
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