Hi all. This is a part of my program, and I have been experiencing some problems.
The program works as intended, but then I thought I should add in some error checking into it. When I prompt the user to input numbers, I would like the program to ask the user to input the number again if he/she entered a non-number. However, the way I've written the code right now just seems to print the error message infinate times.
Can someone give some advice? Thanks.
Code:
int readlist(int arr[], int siz)
{
int i;
int status;
int ch;
printf("\nEnter %i numbers: \n", siz);
for(i = 1; i < siz + 1; i++)
{
printf("%i) ", i);
status = scanf("%i", arr++);
while(status != 1)
{
printf("What? Naw... Again pls.. \n");
status = scanf("%i", arr);
}
}
return *arr;
}