C/C+中字符(A)的大小
#include <stdio.h>int main(){ printf("Size of char : %d\n",sizeof(char)); return 0;}
#include <iostream>int main(){ std::cout<<"Size of char : "<<sizeof(char)<<"\n"; return 0;}
Size of char : 1
'a'
,'b'
,'c'
,'|'
在C中:
#include <stdio.h>int main(){ char a = 'a'; printf("Size of char : %d\n",sizeof(a)); printf("Size of char : %d\n",sizeof('a')); return 0;}
Size of char : 1Size of char : 4
在C+中:
#include <iostream>int main(){ char a = 'a'; std::cout<<"Size of char : "<<sizeof(a)<<"\n"; std::cout<<"Size of char : "<<sizeof('a')<<"\n"; return 0;}
Size of char : 1Size of char : 1
sizeof('a')
跃然一笑
犯罪嫌疑人X
拉丁的传说