enum을 평가할 방법이 있습니까?enum을 평가하는 중
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;
열거에 대한 나의 인쇄 문은 다음과 같습니다 :
data[i].meet_days == MW ? "MW" : "TR"
내가 뭘하려고 오전에만 인쇄 할 sched_record 내 타입 정의 구조체를 얻는 것입니다 내가 구조체에 포함되는 열거가 그 안에 MW라고 쓰여있는 기록들. 다음과 같이 프로그램 내 "메뉴"입니다 :
fread(data, sizeof(sched_record), MAX_RECORD, filePointer);
fclose(filePointer);
printf("Enter the Department or A for any 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);
나는 간단한 문장과 시간에 의해 인쇄 내 sched_records을 가지고 : 간단한 방법 등이 있는지 궁금하고
else if ((strcmp(tempDept, "A")==0) && tempCourse == 0 && (strcmp(tempDay, "D")==0) && (strcmp(tempTime, "P")==0)) {
if (data[i].start.hour >= 12) { // <---Time comparison
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 ((strcmp(tempDept, "A")==0) && tempCourse == 0 && (strcmp(tempDay, "M")==0) && (strcmp(tempTime, "D")==0)) {
printf("\n%s %d", data[i].Dept, data[i].course);
enum과 같은 시간 비교. 그렇다면 누군가 나를 보여줄 수 있습니까?
태그 소켓 소켓을 언급하지 않는 질문에 태그를하지 마십시오 원거리 비교 모든 시간을 일을하지 않고 일 동안 추가로 임의 분류를 추가 할 수 있습니다. 나는 같은 이유로 적어도 당신의 질문 하나를 언약해야만했습니다. –
@JonathanLeffler 죄송합니다. 이것은 소켓 프로그램의 일부이지만 아이디어가 있습니다. –
왜 if (data [i] .meet_days == MW)'할 수 없습니까? – twain249