using comparative operator on a typedef struct member
I have tried:
Code:
if (data[i].start.hour >= "1200")
and obviously it does not work for I get an error of:
Code:
comparison between pointer and integer
Is there a way to do a statement with this same process in mind? I am trying to print out a schedule for the classes the meet after 12 noon. If so, how would it be done? I have included I believe the necessary code.
structs:
Code:
typedef enum {MW, TR} days;
typedef struct {
int hour, min;
} Time;
typedef struct {
char Dept[5];
int course, sect;
days meet_days;
Time start, end;
char instr[20];
} sched_record;
And here is my relevant code in its for loop:
Code:
fread(data, sizeof(sched_record), MAX_RECORD, filePointer);
fclose(filePointer);
printf("Enter the Department: ");
scanf("%s", tempDept);
printf("Enter the Course or 0 for any course: ");
scanf("%d", &tempCourse);
printf("Enter the Days; M = MW, T = TTH or D=Don't Care: ");
scanf("%s", tempDay);
printf("Enter the Time; A=Mornings, P=Afternoons or D=Don't Care: ");
scanf("%s", tempTime);
for (i=0; i < MAX_RECORD; i++) {
if (tempCourse == 0 && (strcmp(tempDay, "D")==0) && (strcmp(tempTime, "D")==0)) {
if (strcmp(tempDept, data[i].Dept)==0) {
printf("%s %d %d %2s %02d%02d %02d%02d %s\n", data[i].Dept, data[i].course, data[i].sect, data[i].meet_days == MW ? "MW" : "TR",
data[i].start.hour, data[i].start.min, data[i].end.hour, data[i].end.min, data[i].instr);
}
}
else if (tempCourse == 0 && (strcmp(tempDay, "D")==0) && (strcmp(tempTime, "A")==0)) {
if (strcmp(tempDept, data[i].Dept)==0) {
if (data[i].start.hour >= "1200"){ // <-- THIS LINE
printf("\n%s %d", data[i].Dept, data[i].course);
}
}
}