I have an enum Eg.
enum {
APPLE,
MANGO,
BANANA
}
and a corresponding string array
char fruits[] =
{
"apple",
"mango",
"banana"
}
I need to retrieve the index of string, given I have the string. So given that the string is apple, I need to get 0 and so on. [ Enum
is additionally there, might help the solution]
Is there an elegant way, to save [apple,0],[banana,1]
that is short and simple, that I might use as a macro. I don't need lengthy things like a hashtable. Can Enum
assist in the mapping?