函数名:setbuf
功 能: 把缓冲区与流相联
用 法:void setbuf(FILE *steam, char *buf);
程序例:
#include <stdio.h>
char outbuf[50];
int main(void)
{
/* 将outbuf与stdout输出流相连接 */
setbuf(stdout,outbuf);
/* 向stdout中放入一些字符串 */
puts("This is a test of buffered output.");
puts("This output will go into outbuf");
puts("and won't appear until the buffer");
puts("fills up or we flush the stream.
");
/* 以下是outbuf中的内容 */
puts(outbuf);
/*刷新流*/
fflush(stdout);
return 0;
}