64,643
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
#include<string>
using namespace std;
int main(){
string line;
string abc("hello world\n");
cout<<"please enter some words"<<endl;
while(getline(cin,line))
cout<<line<<endl;
cout<<abc[1]<<endl;
return 0;
}
1) while(getline(cin,line)) //输入some words 到line,如果输入错误或者按Ctrl+Z 则程序跳转到 3),否则进入2)
2) cout<<line<<endl; //输出line,然后继续 1)
3) cout<<abc[1]<<endl;