Possible Duplicate:
Size of character ('a') in C/C++
OS: linuxmint 32-bit
Compiler: gcc & g++
I have try this code:
#include <stdio.h>
int main()
{
printf("%d\n",sizeof('a'));
return 0;
}
and I compile it with gcc , the result is 4
, and I change to g++, and it is 1
then I use:
sizeof(char)
, and the result is 1
I use: char s = 'a'; printf('%d\n', sizeof(s));
and the result is 1
but I search in the Internet, and some people said that they get the result of 1
or 2
.
So why there are so many different result?