IO库 8.2

题目:编写一个测试函数,将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 }

 

posted @ 2016-01-07 11:17  jasaiq  阅读(111)  评论(0编辑  收藏  举报