Im trying to use isdigit to invoke an error if a string has anything other than a digit in it and having no luck. My old code line will kick out something that starts with a non integer value, ex. e356, it will error but not error out with 3e56. I tried to utilize isdigit in place but I cant seem to get the syntax right. Am I even barking up the right tree trying to invoke isdigit for this kind of task?
// THIS IS BROKEN!!!!
#define MAXLINE 40
int error, n ;
printf("Input a positive integer: ");
fgets(line, MAXLINE, stdin);
//error = sscanf(line, "%d", &n) !=1 || n <= 0;// Old code
error = sscanf(line, "%d", &n) !=isdigit(n); //DOES NOT WORK
printf("\nERROR: Do it again.\n");
printf("your line was: %s",line);