#include
char outbuf[BUFSIZ];
int main()
{
setbuf(stdout,outbuf);
puts("Tis is a test of buffered output.\n");
puts(outbuf);
fflush(stdout);
puts(outbuf);
return 0;
}
输出结果:
This is test of buffered output.
This is test of buffered output.
This is test of buffered output.
This is test of buffered output.
求举例讲解一下setbuf()函数
再把程序一句一句讲一下(主要是outbuf与输出流相连这一句有什么作用不懂),多谢了
setbuf函数自己去百度或者去man下,代码中的三个put输出三条语句,一个fflush输出一句
看不懂,写了三次,输出四次。