编写程序,定义C++语言的不同数据类型的变量,并用sizeof运算符输出所定义的变量在内存中占居的

2024-11-08 12:11:32
有1个网友回答
网友(1):

#include
using namespace std;
int main()
{
int intType;
float floatType;
double doubleType;
char charType;
unsigned char ucharType;
short shortType;
unsigned short ushortType;
long longType;
unsigned long ulongType;
bool boolType;
cout<<"int暂用内存空间的大小:"< cout<<"float暂用内存空间的大小:"< cout<<"double暂用内存空间的大小:"< cout<<"char暂用内存空间的大小:"< cout<<"short暂用内存空间的大小:"< cout<<"long暂用内存空间的大小:"< cout<<"bool暂用内存空间的大小:"< cout<<"unsigned char暂用内存空间的大小:"< cout<<"unsigned short暂用内存空间的大小:"< cout<<"unsigned long暂用内存空间的大小:"<
return 0;
}