当前位置:网站首页>I/O stream summary
I/O stream summary
2022-08-04 14:37:00 【51CTO】
I don't know the exact situation yet,There is a vague understanding,It will be updated continuously in the future
输入流:It's the equivalent of poking a hose into the program,Everything you type is put into the pipe in turn,<<Equivalent to you putting something in a pipe
输出流:This is another hose that pokes into the program,Everything he has calculated is put here,>>Equivalent to you taking something from a water pipe
举个例子
cin>>a>>b;
Equivalent to you putting one in the streama,一个空格,一个b,一个回车;
程序的执行结果是:

One might ask where the whitespace in the stream went?
getchar()The function of the function is to read a string from the keyboard,并带回显,getchar()The function waits for input until exit is pressed,All entered characters before the carriage return are displayed one by one on the screen,但只有第一个字符作为函数的返回值.
读入2The spaces in the middle of the numbers are automatically filtered by the system,Otherwise, the system would not be so stupid
如果你输入1空格2空格回车,spaces will be output,The first space was skipped by the system,The second space will not be skipped by the system
程序的运行结果是:

刚开始输入456,4被getchar()读了,The remaining characters are left in the stream,When the program reads it again, the stream is left behind5给读出来了
scanf和cin结束的'\n'stay in the flow,If encountered, it can be read'\n'的函数,These functions will read in'\n'结束,Nothing else will be entered,能读入'\n'的函数有getchar(),gets(),cin.getline(),
程序的运行结果是:

只输入一个4程序就跑完了,gets()读入的是'\n'
最后总结一下吧,If you just started typing a alphanumeric or something,后面又有一个gets()之类的函数,It should be in the stream'\n'If you eat it, it will be eaten by the next one, which will cause an error,If the following input function will not read in'\n'Then he will'\n'automatically discarded,这个'\n'It doesn't matter if you eat it or not
运行结果:

这样就对了
边栏推荐
- leetcode:251. 展开二维向量
- FRED Application: Capillary Electrophoresis System
- 化繁为简,聊一聊复制状态机系统架构抽象
- 用于X射线聚焦的复合折射透镜
- 【Web技术】1401- 图解 Canvas 入门
- Basic Introduction for PLSQL
- CF1527D MEX Tree(mex&树&容斥)
- ICML 2022 | 图神经网络的局部增强
- Kyushu Cloud attended the Navigator Online Forum to discuss the current status, challenges and future of 5G MEC edge computing
- Lixia Action | Kyushu Yunzhang Jinnan: Open source is not a movement for a few people, popularization is the source
猜你喜欢

谷歌插件.crx文件下载后被自动删除的解决方法
![[The Art of Hardware Architecture] Study Notes (1) The World of Metastability](/img/ac/54e4e13d9df90e96933c69623b770e.png)
[The Art of Hardware Architecture] Study Notes (1) The World of Metastability

Go 语言快速入门指南: 变量和常量

NPDP|作为产品经理,如何快速提升自身业务素养?

爬虫——selenium基本使用、无界面浏览器、selenium的其他用法、selenium的cookie、爬虫案例

用了TCP协议,就一定不会丢包吗?

The Internet of things application development trend

杭电校赛(逆袭指数)

快解析结合友加畅捷U+

eNSP-小型网络拓扑(DNS、DHCP、网站服务器、无线路由器)
随机推荐
leetcode:250. 统计同值子树
leetcode: 253. How many meeting rooms are required at least
Hangzhou Electric School Competition (Counter Attack Index)
Centos7 install mysql version rapidly
centos7安装mysql急速版
How to Identify Asynchronous I/O Bottlenecks
Find My技术|防止你的宠物跑丢,苹果Find My技术可以帮到你
CF1527D MEX Tree(mex&树&容斥)
爬虫——selenium基本使用、无界面浏览器、selenium的其他用法、selenium的cookie、爬虫案例
Technology sharing | Mini program realizes audio and video calls
属于程序猿的浪漫
理论篇1:深度学习之----LetNet模型详解
[in-depth study of 4 g / 5 g / 6 g project - 50] : URLLC - 16 - the 3 GPP URLLC agreement, specification, technical principle of depth interpretation - 10 - high reliability technology - 1 - low codin
物联网应用发展趋势
Almost all known protein structures in the world are open sourced by DeepMind
Hangzhou electric the competition team arrangement (ACM)
js深拷贝和浅拷贝具体使用区别_es6深拷贝和浅拷贝
Keycloak 6.0.0 正式发布,身份和访问管理系统
集合划分差最小问题(01背包)
leetcode:254. 因子的组合