想確認輸入的是數字,結果報錯
#include <stdio.h>
#include <stdlib.h>
int get_int(void);
int main(void)
{
int start;
start = get_int();
int get_int(void)
{
int input;
char ch;
while (scanf("%d", &input) == 1)
{
while ((ch = getchar()) != '\n')
putchar(ch);//剔除錯誤的輸入
printf("is not an integer.\nPlease enter an\ninteger value,such as 25,178or 3;");
}
return input;
}
system("pause");
}
start = get_int();寫在實現的下面