types - Operator sizeof() in C -


consider program

main()   {    printf("%d %d %d",sizeof('3'),sizeof("3"),sizeof(3));   } 

output gcc compiler is:

4 2 4 

why so?

assuming running on 32-bit system:

sizeof character literal '3' 4 because character literals ints in c language (but not c++).

sizeof "3" 2 because array literal length 2 (numeral 3 plus null terminator).

sizeof literal 3 4 because int.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -