Is their a simple way to initialize a typedef enum to a string in C? For example, I would like to initialize the following typedef enum to its string counterpart:
typedef enum
{
ADD,
PLUS, MINUS, MUL, DIV, MOD,
AND, OR, NOT,
BROKEN_FOO
} foo;
Just like how one initializes any string in C (char* foo = "+"
), how could I initialize each member of foo to its string counterpart? e.g. MINUS = "-" etc. I know that each member is represented as an int, but I'm not sure how to go about this, given that each member is represented as an int.