c语言的fprintf用法,c语言中fprintf什么意思

首页 > 教育培训 > 作者:YD1662023-06-03 13:42:59

原函数:

int fflush(FILE *stream)

函数说明: int fflush(FILE *stream)流刷新输出缓冲区。

参数:

返回值:

函数返回零值成功。如果出现错误,则返回EOF并设置错误指示灯(即feof)。

如何使用fflush() 函数:

#include <stdio.h>

int main() {

char buff[1024];

memset( buff, '', sizeof( buff ));

fprintf(stdout, "Going to set full buffering on \n");

setvbuf(stdout, buff, _IOFBF, 1024);

fprintf(stdout, "This is myfoal.com \n");

fprintf(stdout, "This output will go into buff \n");

fflush( stdout );

fprintf(stdout, "will come after sleeping 5 seconds \n");

sleep(5);

return 0;

}

编译和运行上面的程序,产生如下结果。

Going to set full buffering on

This is myfoal.com

This output will go into buff

will come after sleeping 5 seconds

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.