Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7883545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:33:39+00:00 2026-06-03T04:33:39+00:00

Is there a way to evaluate an enum? I have an enum that is

  • 0

Is there a way to evaluate an enum? I have an enum that is incorporated into a struct:

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;

My print statement for the enum is:

 data[i].meet_days == MW ? "MW" : "TR"

What I am trying to do is to get my typedef struct of sched_record to print only the records with say MW in it. My “menu” for the program is as follows:

 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);

I got my sched_records to print out by time with a simple statement of:

 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);

I am wondering if there is a simple way like the time comparison to do the same with the enum. If so can someone show me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:33:41+00:00Added an answer on June 3, 2026 at 4:33 am

    You can compare enumerated values in the same way as any other integer variable:

    if (data[i].meet_days == MW)
      .....
    

    Or, if say you had an enumeration for all days:

    enum days {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday};
    

    then you can test ranges like this:

    if (day >= Monday || day <= Friday)
      printf ("It's a weekday!\n");
    

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way in C++ to have it evaluate each floating point operation
My manager tells me that there is a way to evaluate names that are
Is there an easy way to evaluate strings like (4+8)*2 So that you'd get
Is there a way to evaluate the minimum requirements of a software? I mean,
Is there a way to to evaluate a boolean expression and assign its value
Is there a way to convince the C preprocessor to evaluate a transcendental function
Is there way that I can read the file from remote server using fopen
Is there any way to evaluate a string expression in XSL? example: <myItem id=1>
Is there a nice way to evaluate a regular expression range, say, for a
Is there a way to bulk evaluate the contents of an array in C++?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.