I tried out this code as a C program {some filename.c} and the output observed was 1, 4
#include<stdio.h>
int main()
{
char ch='A';
printf("%d%d",sizeof(ch),sizeof('A'));
}
then i tried the same code as a C++ program {some filename.cpp}
{no other changes made... all i did was File --> Save As --> filename.cpp}
and to my surprise, the output was 1,1.
does this mean that C and C++ have different ways of handling sizeof operator ??
please clarify.
PS : i use Dev CPP on Windows XP.


Sign In
Create Account


Back to top









