页首Html代码

c++ 读取stdin 获取标准输出内容

 1 #include <iostream>
 2 using namespace std;
 3 
 4 #define buf_size 128
 5 
 6 int main()
 7 {
 8     char buf[buf_size] = { 0 };
 9     while(1)
10     {
11         fgets(buf, buf_size, stdin);  //从标准输入读取数据
12         if(buf[0] == 0)
13             break;
14         cout << buf;
15         memset(buf, 0, buf_size);
16     }
17     return 0;
18 }

 

posted @ 2015-09-18 14:42  菩萨心肠金刚手段  阅读(2925)  评论(0编辑  收藏  举报
页脚Html代码