70,037
社区成员
发帖
与我相关
我的任务
分享/*******************************************************************
*第二个版本(申明全局变量)
*******************************************************************/
#include <stdio.h>
char outbuf[50];
int main(void)
{
int s=0;
/* 将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.\n");
/* 以下是outbuf中的内容 */
puts(outbuf);
/* 刷新流 */
fflush(stdout);
/* 打印数组包含的内容 */
for(s=0;s<50;s++)
{
printf("%c",outbuf[s]);
}
printf("\n");
return 0;
}