sizeof('z') result unexpected [duplicate]
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Size of character ('a') in C/C++ Why does this program output 4 and not 1? void main() { printf("%d",int(sizeof('z'))); } 'z' is a character and sizeof('z') must print 1? 回答1: 'z' is a character literal and in C a character literal is of type int . So sizeof('z') equals sizeof(int) on your implementation. 回答2: Sizeof char. Perhaps surprisingly, character constants in C are of type int , so sizeof('a') is sizeof