c++中cin对象中getline()方法和get()方法的区分
来源:互联网 发布:网站域名申请 编辑:程序博客网 时间:2024/06/03 17:05
getline 和get的区别:
getline 每次读取一行,舍弃最后的换行符,下一个getline来的时候,直接读取下一行!
get每次读取一行,但是将每一行最后的换行符保留在输入队列中!下一个get来的时候,先读取输入队列中的换行符!
#include <iostream>using namespace std;int main(){ const int Size=20; char s1[Size]; char s2[Size]; cout<<"Enter the s1"<<endl; cin.get(s1,Size); cout<<"Enter the s2"<<endl; cin.get(s2,Size); cout<<"s1:"<<s1<<endl; cout<<"s2:"<<s2<<endl; return 0;}
#include <iostream>using namespace std;int main(){ const int Size=20; char s1[Size]; char s2[Size]; cout<<"Enter the s1"<<endl; cin.get(s1,Size); cout<<"Enter the s2"<<endl; cin.get(s2,Size); cout<<"s1:"<<s1<<endl; cout<<"s2:"<<s2<<endl; return 0;}
0 0
- c++中cin对象中getline()方法和get()方法的区分
- C++中cin,cin.get()和cin.getline()的区别
- C++中cin,cin.get()和cin.getline()的区别
- c++中cin,cin.get()和cin.getline()的比较
- C++中cin.get和cin.getline的区别
- c++中cin,cin.get和cin.getline比较
- C++中cin,cin.get,cin.getline()的区别
- C++ 中 cin cin.get() cin.getline()的用法
- 区分cin,cin.get(),cin.getline(),getline
- C++ cin.get()和cin.getline()方法详解及区别
- C/C++中cin,cin.getline,getline的用法
- C++中几个输入函数的用法和区别(cin、cin.get()、cin.getline()、getline()、gets()、getchar()))
- c++中输入字符串--cin.get和cin.getline用法
- C++中cin、cin.get()、cin.getline()、getline()、gets()等
- C++中cin、cin.get()、cin.getline()、getline()
- C++中cin、cin.get()、cin.getline()、getline()、gets()等
- C++中cin、cin.get()、cin.getline()、getline()、gets()等
- C++中cin、cin.get()、cin.getline()、getline()
- C语言文件操作函数大全
- C/C++ 常用的一些函数
- 让一个精灵接受触摸事件
- U-BOOT源码分析及移植
- 《3D豪情》百度影音高清在线观看BD种子下载1.9G
- c++中cin对象中getline()方法和get()方法的区分
- CCSpriteBatchNode
- 如何解决phpcms后台验证码不显示的问题
- 开启centos防火墙的8080端口
- NandFlash驱动和Yaffs文件系统的移植
- FPGA机器学习之stanford机器学习第一堂
- 正则表达式之作用
- 写给24岁的自己
- 混沌------分岔图绘制不同方法的总结、比较(转)