帮我看看这个例子,怎么错了
#include <iostream>using namespace std;
#include<string>
int main()
{
string str;
char s[] = "12345";
str.reserve(5);
for (int i = 0; i < 5; i++)
str[i] = s[i];
cout << "str:" << str << endl;
cout << "length():" << str.length() << endl;
system("pause");
return 0 ;
}
[此贴子已经被作者于2021-8-16 11:23编辑过]