Testing user input question?
I have a program that requires a user to input a number. The number determines how many random numbers(done by my program) will be displayed on the screen. The number input by the user will be of type int. Is it legal to use an isalpha() function to test and see if it actually is an int. Eg. if someone types in 46i instead of 461. Would this be a correct way to check it. I'm not at my PC with my compiler right now so I'm just trying to get close.
Thanks for any help.
void get_info(char *filename, int *n_ptr)
"This progam creates a file of random numbers.",
"Please enter in the number of random numbers
you would like to see as a positive integer. "),
if (scanf("%d", n_ptr)) != 1 || n_ptr <=0 || isalpha(n_ptr)
printf("\nERROR: Please enter positive integer.\n");
printf("\nIn what file would you like them? ");