string类中getline函数的应用

*/
 * Copyright (c) 2016,烟台大学计算机与控制工程学院
 * All rights reserved.
 * 文件名:text.cpp
 * 作者:常轩
 * 微信公众号:Worldhello
 * 完成日期:2016年5月14日
 * 版本号:V1.0
 * 问题描述:string类中getline函数的应用
 * 程序输入:无
 * 程序输出:见运行结果
 */
//string类中getline函数的应用
#include <iostream>
#include <string>
using namespace std;
inline void test(const char*title,bool value){
cout<<title<<"returns"<<(value?"true":"false")<<endl;
}
int main()
{
   for(int i=0;i<2;i++)
   {
       string city,state;
       getline(cin,city,',');
       getline(cin,state);
       cout<<"city:"<<city<<"    state:"<<state<<endl;
   }
    return 0;
}


运行结果:


posted @ 2016-05-19 21:41  壹言  阅读(195)  评论(0编辑  收藏  举报