Hello all! Trying to finish up my last programming assignment for the semester. In the beginning of the program I created a struct, and one of the individual elements of the struct is a character string called "action". What I want to do is IF action is ____, then do this. I'm getting all sorts of compiler errors. I'm only going to post the code from the function I wrote it in, but if you want to see the struct or main, let me know.
Code:
int readfile(FILE *ifp, struct class student[]){
int num, index;
//Read in number of records.
fscanf(ifp, "%d", &num);
//Read in each record one by one.
for (index=0; index<num; index++) {
fscanf(ifp, "%s", student[index].last);
fscanf(ifp, "%s", student[index].first);
fscanf(ifp, "%s", student[index].action);
//If they took a class or are doing grade forgiveness,
// only scan in hours and grade.
if(student[index].action == 'TOOK_CLASS' ||
student[index].action == 'GRADE_FORGIVE'){
fscanf(ifp, "%d", &student[index].hours);
fscanf(ifp, "%s", student[index].grade);
}
//If they are changing their grade, scan in hours, old grade, and new grade.
if(student[index].action[] == 'CHANGE_GRADE'){
fscanf(ifp, "%d", &student[index].hours);
fscanf(ifp, "%s", student[index].grade);
fscanf(ifp, "%s", student[index].newgrade);
}
}
return num;
}
Thanks!