Have the code below which is producing an infinite loop. It's checking to see if the user gave an integer for the input, and if not then it should perform another loop iteration to ask again. What's occurring is it prompts the user, and if the user doesn't input an integer then the loop runs indefinitely without asking the user again for a new integer. I would EXPECT it to, but that's not what it's doing.
int arrowBaseHeight = 0;
int arrowBaseWidth = 0;
int arrowHeadWidth = 0;
int rc = 0; //Return code of user input
do {
printf("Enter arrow base height greater than 1:\n");
rc = scanf("%d", &arrowBaseHeight);
} while (arrowBaseHeight < 1 || rc == 0);
Why is it doing this, and anyone know a way to fix it?
Thank you all so much.