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

  • Home
  • SEARCH
  • 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 9255151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:38:59+00:00 2026-06-18T11:38:59+00:00

How to get enum count I have a Enum typedef enum{ DEL_TIME_VALUE = -1,

  • 0

How to get enum count

I have a Enum

typedef enum{

DEL_TIME_VALUE    = -1,
DEL_TIMESEC_VALUE = 100,
DEL_TIMEMIN_VALUE = 200,
DEL_TIMEHOUR_VALUE = 300,
DEL_DAY_VALUE      = 1000,
DEL_COUNT_VALUE    = 1000,
....
.....
.....
DEL_END             =90002
}WORKINGTIME;

How do i get the enum count.

I try below for loop!

for(int i=DEL_TIME_VALUE; i<=DEL_END; i++) {

}

I guess its not good one!

can any one tell me how to get enum count! which are declared in enum.

Thanks in advance!

  • 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-18T11:39:00+00:00Added an answer on June 18, 2026 at 11:39 am

    You can’t.

    There is one technique that allows you to get the enum count. It looks like

    typedef enum {
        value_one,
        value_two,
        value_three,
        ...
        enum_count
    } my_enum;
    

    Now the value enum_count is the count of values in the enum. However, this technique only works if the enums all carry their implicit value, where value_one is 0, value_two is 1, etc. Because of this, the last value in the enum always has the value of the count of enum values. In your case, your enum constants have explicit values that are not monotonically incrementing. There is no way to derive a count from this type of enum. And even in the theoretical world where you could derive a count, that wouldn’t help you because you could not derive the value of a given enum constant.

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

Sidebar

Related Questions

how to get count based on enum status using self join I have a
Assume I have an enumerable object enum and now I want to get the
I have wrapped a struct around an enum to get a scoped enum. E.g.:
What I'm trying to do is get Enum Type from string. example: //enum which
What i'm trying to do is get Type of enum which is nested in
How can I get the number of items defined in an enum?
Is there a way to get all possible values from a MySQL enum column?
I have an implementation for printing out enum values in c++ If I put
Does anyone know how to get enum values to string? example: private static void
I have an enum representing all material assembly codes in the system: public enum

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.