admin管理员组文章数量:1123010
c/c++基本类型sizeof:short,unsigned short,int,unsigned int,long,unsigned long,long long,unsigned long lon
- 类型字节表
|
|
|
| X86 | X86_64 |
short | signed short | short int | signed short int | 2 | 2 |
unsigned short |
|
| unsigned short int | 2 | 2 |
int | signed | signed int |
| 4 | 4 |
unsigned int | unsigned |
|
| 4 | 4 |
long | signed long | long int | signed long int | 4 | 8 |
unsigned long |
|
| unsigned long int | 4 | 8 |
long long | signed long long | long long int | signed long long int | 8 | 8 |
unsigned long long |
|
| unsigned long long int | 8 | 8 |
- 注意:
x86&x86_64 | 有char总为1字节 |
x86&x86_64 | 有short总为2字节 |
x86 | 有long long就是8字节 |
x86_64 | 有long就是8字节 |
- 例子
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
cout << "sizeof short:" << sizeof(short) << endl;
cout << "sizeof unsigned short:" << sizeof(unsigned short) << endl;
cout << "sizeof int:" << sizeof(int) << endl;
cout << "sizeof unsigned int:" << sizeof(unsigned int) << endl;
cout << "sizeof long:" << sizeof(long) << endl;
cout << "sizeof unsigned long:" << sizeof(unsigned long) << endl;
cout << "sizeof long long:" << sizeof(long long) << endl;
cout << "sizeof unsigned long long:" << sizeof(unsigned long long) << endl;
return 0;
}
本文标签: cc基本类型sizeofshortunsigned shortintunsigned intlong
版权声明:本文标题:cc++基本类型sizeof:short,unsigned short,int,unsigned int,long,unsigned long,long long,unsigned long lon 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/biancheng/1708354428a742406.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论