0
点赞
收藏
分享

微信扫一扫

c++ sizeof

滚过红尘说红尘 2023-01-13 阅读 85


#include <iostream>
using namespace std;

int main()
{
cout << "Size of char : " << sizeof(char) << endl;
cout << "Size of int : " << sizeof(int) << endl;
cout << "Size of short int : " << sizeof(short int) << endl;
cout << "Size of long int : " << sizeof(long int) << endl;
cout << "Size of float : " << sizeof(float) << endl;
cout << "Size of double : " << sizeof(double) << endl;
cout << "Size of wchar_t : " << sizeof(wchar_t) << endl;
return 0;
}

Size of char : 1
Size of int : 4
Size of short int : 2
Size of long int : 8
Size of float : 4
Size of double : 8
Size of wchar_t : 4

char  1 个字节 -128 到 127 或者 0 到 255==2**8

unsigned int  4 个字节 0 到 4294967295==2**32

一个字节等于8个二进制位


举报

相关推荐

0 条评论