码迷,mamicode.com
首页 > 其他好文 > 详细

IO库 8.2

时间:2016-01-07 11:35:19      阅读:115      评论:0      收藏:0      [点我收藏+]

标签:

题目:编写一个测试函数,将cin作为参数传入。

 1 #include <iostream>
 2 using std::istream;
 3 
 4 istream& func(istream& is)
 5 {
 6     std::string buf;
 7     while (is >> buf) std::cout << buf << std::endl;
 8     is.clear();
 9     return is;
10 }
11 
12 int main()
13 {
14     istream& is = func(std::cin);
15     std::cout << is.rdstate() << std::endl;
16     return 0;
17 }

 

IO库 8.2

标签:

原文地址:http://www.cnblogs.com/ykzou/p/5109133.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!