clear.c
来自「c21Examples.rar」· C语言 代码 · 共 28 行
C
28 行
/* Clearing stdin of extra characters. */
/* Using the fflush() function */
#include <stdio.h>
int main( void )
{
int age;
char name[20];
/* Prompt for user's age. */
puts("Enter your age.");
scanf("%d", &age);
/* Clear stdin of any extra characters. */
fflush(stdin);
/* Now prompt for user's name. */
puts("Enter your first name.");
scanf("%s", name);
/* Display the data. */
printf("Your age is %d.\n", age);
printf("Your name is %s.\n", name);
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?