在C++中如何存储不定长字符串
来源:百度知道 编辑:UC知道 时间:2024/05/20 22:04:58
字符串是键盘输入的
用C++定义的string类
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s;
cin >> s;
cout << s << endl;
return 0;
}
设一个字符数组s[100]
好像用指针也行
UC知道是一部内容开放、自由的互动网络百科全书
客观、专业、权威的知识性百科全书
来源:百度知道 编辑:UC知道 时间:2024/05/20 22:04:58
用C++定义的string类
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s;
cin >> s;
cout << s << endl;
return 0;
}
设一个字符数组s[100]
好像用指针也行