当前位置:网站首页>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
运行结果:
这样就对了
边栏推荐
- F.金玉其外矩阵(构造)
- How to automatically renew the token after it expires?
- 1401 - Web technology 】 【 introduction to graphical Canvas
- F. Jinyu and its outer matrix (construction)
- 快解析结合友加畅捷U+
- Bluetooth Technology|In the first half of the year, 1.3 million charging piles were added nationwide, and Bluetooth charging piles will become the mainstream of the market
- Cisco-小型网络拓扑(DNS、DHCP、网站服务器、无线路由器)
- 关于redis的几件小事(五)redis保证高并发以及高可用
- 1375. 二进制字符串前缀一致的次数-前序遍历法
- How to install postgresql and configure remote access in ubuntu environment
猜你喜欢
Find My技术|防止你的宠物跑丢,苹果Find My技术可以帮到你
Sum of four squares, laser bombs
世间几乎所有已知蛋白质结构,都被DeepMind开源了
MySQL【触发器】
开发者独立搭建一个跨模态搜索应用有多难?
NPDP|作为产品经理,如何快速提升自身业务素养?
本周讨论用户体验:Daedalus 的 Nemo 加入 Ambire,探索加密海洋
Database recovery
The Internet of things application development trend
Google plug-in. Download contents file is automatically deleted after solution
随机推荐
[Beiya data recovery] IBM System Storage storage lvm information lost data recovery solution
leetcode:253. 至少需要多少间会议室
Cisco - Small Network Topology (DNS, DHCP, Web Server, Wireless Router)
世间几乎所有已知蛋白质结构,都被DeepMind开源了
leetcode: 212. Word Search II
Almost all known protein structures in the world are open sourced by DeepMind
CloudCompare&PCL 点云按网格划分(点云分幅)
leetcode:254. 因子的组合
Technology sharing | Description of the electronic fence function in the integrated dispatching system
利用决策树找出最优特征组合
广告电商系统开发功能只订单处理
关于redis的几件小事(五)redis保证高并发以及高可用
leetcode: 253. How many meeting rooms are required at least
[Opportunity Enlightenment-60]: "Soldiers, Stupid Ways"-1- Opening: "Death" and "Life" are the way of heaven
期货开户之前要谈好最低手续费和交返
【北亚数据恢复】IBM System Storage存储lvm信息丢失数据恢复方案
B.构造一个简单的数列(贪心)
How to automatically renew the token after it expires?
1375. 二进制字符串前缀一致的次数-前序遍历法
2042. 检查句子中的数字是否递增-力扣双百代码-设置前置数据