I am attempting to check whether certain variables read in from a file are integers are not, and if they aren't ignore them and go on with the printing of an error message. So I am using isdigit() to see if the variables are ints or not and it keeps working "backwards" in a sense.
int parseStudent(struct student *person, char *data){
char *ptr;
int temp;
int i = 0;
ptr = strtok(data, DELIM);
temp = atoi(ptr);
if(isdigit(temp)){printf("Invalid TERM integer!\n");}
//if(!isdigit(temp)){printf("Invalid TERM integer!\n");}
//person[i].term = temp;
ptr = strtok(NULL, DELIM);
person[i].id = atoi(ptr);
ptr = strtok(NULL, DELIM);
strcpy(person[i].lastname, ptr);
ptr = strtok(NULL, DELIM);
strcpy(person[i].firstname, ptr);
ptr = strtok(NULL, DELIM);
strcpy(person[i].subjectname, ptr);
ptr = strtok(NULL, DELIM);
person[i].catalog = atoi(ptr);
ptr = strtok(NULL, DELIM);
strcpy(person[i].section, ptr);
}
Now as you can see with my first check my intent is to see if that first temp int (which is suppose to hold an int, it does "1301") is in fact an integer. When I use the uncommented line, it fails the condition and nothing is printed. When I use the commented line it prints my error message. Isn't that backwards!? How do I check these ints and strings to in fact be ints and strings and report errors on the face?