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)
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With