I know that every literal in C and C++ get a specific type information. I have written this little program in C and compiled this in Visual Studio 2012. The source file is called 'main.c'.
#include <stdio.h>
int main()
{
printf("sizeof(char) = %d\n",sizeof(char));
printf("sizeof('i') = %d",sizeof('i'));
getchar();
return 0;
}
Output:
sizeof(char) = 1
sizeof('i') = 4
I wondered that the size of a character wasn't 1 Byte. I renamed the source file to 'main.cpp' and now sizeof('a') returned 1 as previously expected. So there must be a language specific difference. Why is the size of a char in C 4 Byte and not 1 ?