C++中的int和short int

 1 #include <iostream> 
 2 #include <string>
 3 #include <cstring>  //strcpy
 4 #include <cstdlib>  //malloc
 5 #include <cstdio>  //printf
 6 
 7 using namespace std; 
 8 
 9 int main(){
10 
11     cout<<sizeof(int)<<endl;
12     cout<<sizeof(short int)<<endl;
13     cout<<sizeof(unsigned int)<<endl;
14     cout<<sizeof(unsigned short int)<<endl;
15 
16     return 0;
17 }

在64位的Fedora下(编译器为G++)运行结果为:

4
2
4
2


 

posted @ 2016-04-01 14:18  hu983  阅读(913)  评论(0编辑  收藏  举报