Chinaunix首页 | 论坛 | 博客
  • 博客访问: 243379
  • 博文数量: 83
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 410
  • 用 户 组: 普通用户
  • 注册时间: 2012-08-22 10:11
文章分类
文章存档

2016年(2)

2014年(2)

2013年(65)

2012年(14)

我的朋友

分类: LINUX

2013-01-26 14:23:44

原文地址:fflush函数 作者:yuchuan2008

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

#include
#include

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
 
阅读(1228) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~