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 8195825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:16:08+00:00 2026-06-07T05:16:08+00:00

If have an enumeration like so: typedef enum { ValueOne = /* some arbitrary

  • 0

If have an enumeration like so:

typedef enum {
    ValueOne = /* some arbitrary number, NOT necessarily 0 */,
    ValueTwo = /* another number, NOT necessarily consecutive */
} MyEnumeration;

I was wondering if there is any way to get an array out of it and access a value at a specific index without doing this:

int array[2] = {ValueOne, ValueTwo};
MyEnumeration value = array[provided_index];

My problem is that in my project, the enumerations have 10-15 values, and I’d rather not create an array out of each one of them.

[Edit]: I can see how this would not be possible since typedef and enum aren’t tied together at all, but I figured it wouldn’t hurt to ask in case I was missing something.

  • 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-07T05:16:11+00:00Added an answer on June 7, 2026 at 5:16 am

    No.

    You will have to write the code for both the enum and the array, or use some technique to auto-generate code to reduce the maintenance burden.

    This article may of be some interest to you: The New C: X Macros.

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

Sidebar

Related Questions

I have an enumeration like Enum Complexity { NotSoComplex, LittleComplex, Complex, VeryComplex } And
I have an enumeration for my Things like so: public enum Things { OneThing,
I have a class I've written to act like an enumeration: abstract class Enum
In my compiler project, I have an enumeration that goes like enum Result {
I have enumeration like this: public enum Configuration { XML(1), XSLT(10), TXT(100), HTML(2), DB(20);
I have an enumeration which I'd like to persist as a value of some
Possible Duplicate: How to enumerate an enum? Suppose that i have an enumeration like
I have an enumeration that looks like the following public enum MyEnum { A,
I have an Application Delegate class with a enumeration which looks like this: typedef
I have a c# enumeration that looks like this: public enum EthernetLinkSpeed { [Description(10BASE-T)]

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.