//5. Write a C++ program to find size of int, float, double and char.
#include<iostream>
using namespace std;
int main()
{
cout << "string size=" << sizeof(string) << endl;
cout << "int size=" << sizeof(int) << endl;
cout << "float size=" << sizeof(float) << endl;
cout << "double size=" << sizeof(double) << endl;
cout << "char size=" << sizeof(char) << endl;
system("pause");
return 0;
}
输出结果如下:
string size=28
int size=4
float size=4
double size=8
char size=1