一阶段:c++学习代码保存
B站学习练习代码
2.1整型
#include <iostream>
using namespace std;
/*
short,int,long longlong
*/
int main2_1()
{
short a = 1;
cout << sizeof(a)<<sizeof(long);
system("pause");
return 0;
}
#2.2 sizeof关键字
#include <iostream>
using namespace std;
int main2_2()
{
cout << sizeof(int)<<endl;
cout<<sizeof(short)<<endl;
cout<<sizeof(long)<<endl;
cout<<sizeof(long long)<<endl;
system("pause");
return 0;
}
本文介绍了C++初学者如何使用`sizeof`关键字测量不同类型变量的内存占用,通过实例演示了short、int、long和long long的数据类型。
6300

被折叠的 条评论
为什么被折叠?



