Possible Duplicate:
Why are C character literals ints instead of chars?
why sizeof('a') is 4 in C?
#include<stdio.h>
int main()
{
char ch;
fflush(stdin);
ch=getchar();
printf("ch= %d a=%d char=%d", sizeof(ch),sizeof('a'),sizeof(char));
}
I type in 'a' (without quotes) as input , and the output I got in my gcc version 4.5.1 is :
ch= 1 a=4 char=1
My question is :
If sizeof(c)
is 1
, then how can sizeof('a')
be 4
?