char c = 'A';
printf("%d\n",sizeof(c));// output = 1
printf("%d\n",sizeof('A')); // output = 4
Why the sizeof operator gives different output for same character? Please Help
char c = 'A';
printf("%d\n",sizeof(c));// output = 1
printf("%d\n",sizeof('A')); // output = 4
Why the sizeof operator gives different output for same character? Please Help
c is a variable of type char; its size is 1 byte.
'A' is an int literal - don't ask me why the standard says that. Its size is 4 bytes on your platform (the same as sizeof(1)).