in C
printf ("%d",sizeof ('a'));
output: 4
in C++
printf ("%d",sizeof ('a'));
output: 1 Why the outputs do not equal?
in C
printf ("%d",sizeof ('a'));
output: 4
in C++
printf ("%d",sizeof ('a'));
output: 1 Why the outputs do not equal?
In C, the 'a' is considered int
with a size of sizeof(int)
. While in C++, the 'a' is considered a char
with a size of 1.