string类中getline函数的应用
2016-05-19 21:41
477 查看
*/ * 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; }
运行结果:
相关文章推荐
- 顺序表(粗糙版)
- 浪潮之巅读后感
- tomcat连接超时
- window下rabbitmq的配置问题
- Training MNIST LeNet on MNIST with Caffe
- bzoj:4105: [Thu Summer Camp 2015]平方运算
- 找水王
- JAXB - Hello World with Namespace
- LeetCode Word Break II
- 深入浅出Mybatis系列(五)---TypeHandler简介及配置(mybatis源码篇)
- 地址栏上没有显示.jsp后缀的页面,只是显示方法名
- javaScript valueOf和toString方法在不同场景被调用进行数据转换
- 小tips reboot与shutdown -r now 区别与联系
- HttpURLConnection多线程下载
- 316. Remove Duplicate Letters
- Java数组
- 蓝桥杯练习系统—算法训练 P1102
- 使用Cookie进行会话管理
- 第十三周
- Linux及安全——模块