Very very new to C programming and I've created an infinite loop, help - TechRepublic
Question
July 29, 2009 at 01:54 AM
alb10811

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

by alb10811 . Updated 16 years, 11 months ago

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;

}

This discussion is locked

All Comments