C语言问题
为什么我这个会陷入无尽循环啊?
#include <stdio.h>
#include <ctype.h>
int main()
{
char ch;
double num1, num2;
printf("Enter the operation of your choice:\n");
printf("a. add\ts. subtract\nm. multiply\td. divide\nq. quit\n");
ch = getchar();
printf("Enter first number:");
int a=scanf("%lf", &num1);
while (a != 1) {
printf("Please enter a number,such as 2.5,-1.78E8,or 3 :");
a = scanf("%lf", &num1);
}
return 0;
}
输入so之后就会陷入死循环。