getline 函数用法简介
2016-07-11 20:39
239 查看
#include<iostream> #include<cstring> #include<cstdio> using namespace std; //分开执行 int main() { string str1,str2; getline(cin,str1);//读取一行字符串,可读入空格 cout<<str1<<endl; getline(cin,str2,'#');//读到以#作为分界符的一行字符串 cout<<str2<<endl; char a[20]; cin.getline(a,6);//读入5个字符到a中,以'\0'结尾,可读入空格 cout<<a<<endl; char b[20]; cin.getline(b,6,'@');//读入至多5个字符,或读到以‘@’标识的位置前 cout<<b<<endl; return 0; }
相关文章推荐
- 浮点数表示
- 写给自己的一个关于法线讲解的博客地址
- 切图psd to html页面制作技术学习与总结
- 安卓App热补丁动态修复技术介绍
- ios developer tiny share-20160711
- ios developer tiny share-20160711
- 解题报告:LightOJ 1341 Aladdin and the Flying Carpet 唯一分解+DFS
- java虚拟机内存分析
- PCH was compiled with module cache......解决办法
- okhttp
- 代理
- Apache Shiro 退出
- 10、多表数据查询----第2篇
- 网络编程(学习整理)---2--(Udp)实现简单的控制台聊天室
- php必备技能 转载
- 黄浩胜之个人简介
- C++中运算符总结
- POJ 1328 Radar Installation(贪心+区间选点问题)
- leetcode372. Super Pow
- CentOS6中,安装PHP7