电脑怎么用鼠标写字:fflush函数是什么

来源:百度文库 编辑:高校问答 时间:2024/05/12 13:17:43

清除文件缓冲区,文件以写方式打开时将缓冲区内容写入文件
原型:int fflush(FILE *stream)

用法:
/* FFLUSH.C */

#include <stdio.h>
#include <conio.h>

void main( void )
{
int integer;
char string[81];

/* Read each word as a string. */
printf( "Enter a sentence of four words with scanf: " );
for( integer = 0; integer < 4; integer++ )
{
scanf( "%s", string );
printf( "%s\n", string );
}

/* You must flush the input buffer before using gets. */
fflush( stdin );
printf( "Enter the same sentence with gets: " );
gets( string );
printf( "%s\n", string );
}

输出:

Enter a sentence of four words with scanf: This is a test
This
is
a
test
Enter the same sentence with gets: This is a test
This is a test

清除文件缓冲区,文件以写方式打开时将缓冲区内容写入文件
原型:int fflush(FILE *stream)