关于各种类型数据char、int、double、float 所占空间长度的计算,而char类型让我长姿势了

 1 #include  <iostream>
 2 int main()
 3 {
 4     using namespace std;
 5     //int A=10;
 6     //double B=6;
 7     cout << sizeof(int) << endl;
 8     cout << sizeof(double) << endl;
 9     cout << sizeof(float) << endl;
10     cout << sizeof(char);
11     system("pause");
12     return 0
13         ;

上面代码是在vs中运行的c++代码运行结果如下:double 数据占8个字节双精度而char 类型只占一个字节,以前总以为也是4个字节空间

原文地址:https://www.cnblogs.com/Mr210843013/p/4810561.html