sizeof目的:
算出数据类型占用内存的大小
语法:
sizeof(数据类型/变量)
sizeof(数据类型)代码:
#include <iostream>
using namespace std;
int main()
{
int math = 90;
cout << "int占用的内存空间是:" << sizeof(int) << endl;
system("pause");
return 0;
}
sizeof(变量)代码:
#include <iostream>
using namespace std;
int main()
{
int math = 90;
cout << "int占用的内存空间是:" << sizeof(math) << endl;
system("pause");
return 0;
}