Here\'s what I am trying to do:
typedef enum { ONE, TWO, THREE } Numbers;
I am trying to write a function that would do a switch case sim
There's no built-in solution. The easiest way is with an array of char*
where the enum's int value indexes to a string containing the descriptive name of that enum. If you have a sparse enum
(one that doesn't start at 0 or has gaps in the numbering) where some of the int
mappings are high enough to make an array-based mapping impractical then you could use a hash table instead.