Access an enum using an index in C

后端 未结 4 1479
梦毁少年i
梦毁少年i 2021-01-13 09:17

Consider:

enum Test
{
    a = 3,
    b = 7,
    c = 1
};

I want to access the enum using an index. Something like this:

for         


        
4条回答
  •  离开以前
    2021-01-13 09:38

    Your question demonstrates you don't really understand what an enum is for.

    It is not something that can be indexed, nor is there ever any reason to. What you have defined is actually just 3 constants named a, b, and c, whose values are 3, 7, and 1 respectively.

提交回复
热议问题