您的位置:首页 > 编程语言 > C语言/C++

输出操作符和getline读取string对象

2011-05-09 16:05 295 查看
#include <iostream>

#include <string>

using namespace std;

int main()
{
//getline读取string对象
//string line;
//while (getline(cin,line))
//{
// cout<<line<<endl;
// if (line=="exit")
// {
// break;
// }
//}
上述输出结果:




//输入操作符读取string对象 将空格符换行输出
string strLine;
while (cin>>strLine)
{
cout<<strLine<<endl;
if (strLine=="exit")
{
break;
}
}
上述输出结果:




system("pause");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  职场 休闲 getline c++
相关文章推荐