📦 归档笔记 — 原创建于 WizNote,仅作归档展示;观点以当年为准,非最新。

演示非法输入

创建时间2017-12-07最后修改2018-01-31原位置/程序员成长之旅/C语言/别人的源码/字数99
目录:程序员成长之旅/C语言/别人的源码

Ubuntu PastebinPaste from 判断非法输入 at Thu, 7 Dec 2017 14:38:59 +0000

Download as text

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 #include <stdio.h> int main(void) { int a = 0; while(1) { int flag = 0; printf("please input an integer\n"); flag = scanf("%d", &a); if(flag == 1) { printf("valid input\n"); } else { printf("Invalid input\n"); } char c = 0; while((c = getchar() )!= EOF && c != '\n'); } }