我有这个代码。我需要验证用户是否输入了整数,否则要求再次输入。
double num1, num2, num3, num4;
printf("Enter 1st number: \n");
scanf_s("%lf", &num1);
while (scanf_s("%lf", num1 != 2))
{
while (getchar() != '\n');
printf("It is not a digit, try again: \n");
}
printf("Enter 2nd number: \n");
scanf_s("%lf", &num2);
printf("Enter 3rd number: \n");
scanf_s("%lf", &num3);
printf("Enter 4th number: \n");
scanf_s("%lf", &num4);