Hi here is my problem im adding to a program to catch errors.The program below catches errors like integers less than 0 or not equal to 1 but if I put in a number like 223e it doesn't catch the e as an error I know I am missing something in my error = sscanf() line but cant figure it out please help.
Code:
char line[MAXLINE];
int error, n;
do{
printf("Input a positive integer: ");
fgets(line, MAXLINE, stdin);
error = sscanf(line, "%d", &n) != 1 || n<= 0;
if (error)
printf("\nError: Do it again. \n");
} while (error);
Comment