#include<iostream>
#include<string>
using namespace std;
int main()
{
string a, b;
cin >> a >> b;//cin对于字符串中不能有空格;
cout << "a.size()="<<a.size()<<endl;//相当于strlen();
cout <<"sizeof(a)="<< sizeof(a) << endl;//计算占用几个字节;
return 0;
}
有一点:
string不同于int ,double,char ,等.string占用的内存空间是动态分配的,我的电脑最小是28;