首页 > 其他 > 详细

IO库 8.2

时间:2016-01-07 11:32:30      阅读:121      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!