64,653
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <conio.h>
int i = 0;
char c;
void main() {
while (1) {
printf("\nPlease input a number:");
fflush(stdout);
rewind(stdin);
if (2==scanf("%d%c",&i,&c)) {
if ('\n'==c) {
printf("\nThe number is %d.\n", i);
break;
}
}
}
printf("Press any key to end ...");
getch();
}
//
//Please input a number:12a
//
//Please input a number:a
//
//Please input a number:12
//
//The number is 12.
//Press any key to end ...