Please explain the output of sizeof()
问题 I am new in c programming, and I am trying to understand the sizeof function. Please help me understand how this program works: #include<stdio.h> main( ) { printf ( "\n%d %d %d", sizeof ( '3'), sizeof ( "3" ), sizeof ( 3 ) ) ; } I am getting output as 4 2 4 . However, I am not able to understand the reason I get this output. Kindly explain it. 回答1: sizeof ( '3') , it is the size of character constant which is int so you are getting value as 4 on your machine. sizeof ( "3" ) , it is size of