Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

non stop loop

$
0
0
im trying to check if the input is valid... i get non stop loop !!
this is the code:
void one_game()
{
    int NumOfMatches, Max, input,input2, round=0,num;

    printf("\nNumber of matches: ");
   input= scanf("%d",&NumOfMatches );
if (input<1)
printf("invalid input");

    while (NumOfMatches <= 0)
    {
        printf("Number of matches: ");
        input= scanf("%d",&NumOfMatches);
if (input<1)
printf("invalid input");

    }
}



*if i get into the loop and enter a letter it goes non stop !!

Viewing all articles
Browse latest Browse all 51036

Trending Articles