c++可以使用如下方式输入字符串:
方式一:
#include <iostream>
using namespace std;
void main()
{
char s[50];//字符数组,用于存放字符串的每一个字符
cout<<"Please input a string"<<endl;
cin>>s;
cout<<"The string you input is"<<s<<endl;
}
方式2:
#include <iostream>
using namespace std;
void main()
{
char s[50];//字符数组,用于存放字符串的每一个字符
cout<<"Please input a string"<<endl;
cin.get(s,50);//当输入是Enter键时,结束输入
cout<<"The string you input is:"<<s<<endl;
}