I am new to C. I am writing this do while loop but when I accidentally enter a decimal/double to the input, it will enter a infinite loop. Would you please correct me? Thank you!
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
int items;
do {
printf("Input item quantity: ");
scanf("%d", &items);
if (items < 1 || items > 10)
printf("ERROR: It must between 1 - 10.\n");
} while (items < 1 || items > 10);
return 0;
}
If I try to input 300.5, the output will become a loop
```
Input item quantity: ERROR: It must between 1 - 10.
Input item quantity: ERROR: It must between 1 - 10.
Input item quantity: ERROR: It must between 1 - 10.
```