If I want to declare an array of structures in C and have the number of items in that array to correspond to the items of an enumeration, is there a way to access the maximum value in the enumeration when declaring the array?
For instance:
typedef struct
{
various fields....
} fruit_rec;
enum fruit_info {apple, orange, banana}
fruit_rec fruits[3];
Instead of hard-coding a '3' in the 'fruits' declaration, is there a way I can access the number of items in the enumeration? In the old DoD language, Ada, one could do something like, " fruit_rec fruits[fruit_info] " .
I don't think there is a way to do what I'm asking, but I thought I'd ask as it would be a cleaner way of declaring things. Even if I can't do something like that, I know I can still refer to the elements as "fruits[apple}" , "fruits[orange]", etc. Thank you.