This a C program that I wrote for an assignment. I just wanna add some lines of code of my own. But it ended up in a never-ending loop.
I tried using a while loop to solve this, but that is where my problem is.
int tab1[6],c;
printf("\n\nEnter 4 integers in the first array:\n ");
for (c = 0; c < 4; ++c)
{
printf("\n\tValue %d : ",c+1);
scanf("%d",&tab1[c]);
//if tab1[c] is not a number ask again.
while (!isalpha(tab1[c]))
{
printf("nEnter an integer : ");
}
scanf("%d",&tab1[c]);
}
I wanted for the program to ask out for an integer when the user enter something other than an integer.