Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1217268
  • 博文数量: 404
  • 博客积分: 10011
  • 博客等级: 上将
  • 技术积分: 5382
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-03 16:29
文章存档

2010年(40)

2009年(140)

2008年(224)

我的朋友

分类: LINUX

2009-03-04 15:57:24

清除文件缓冲区,文件以写方式打开时将缓冲区内容写入文件 ]
原型: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
 
阅读(1103) | 评论(0) | 转发(1) |
0

上一篇:stat函数说明

下一篇:meminfo信息官方说明

给主人留下些什么吧!~~