Question Locked

Very very new to C programming and I've created an infinite loop, help

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi all

I'm playing with C code after coding with C# and I was trying to validate that user in putted data was an integer, some how all I've managed to do is create an infinite loop. Could someone please look over my code and let me know how to get the desired result.

Thanks

printf("Please enter the number of rectangles you wish to add: ");

isInteger =scanf("%d", &noRectangles);

while (isInteger == 0)
{

printf("Error: Sorry the data you entered was not numerical. Please enter a numerical value. \n");

printf("Please enter the number of rectangles you wish to enter: ");

isInteger =scanf("%d", &noRectangles);
continue;

}

2 replies

This discussion is closed to new replies.