Suppose that, I have following macros that are defined in header file:
# define MACRO_ID_1 1
# define MACRO_ID_2 2
...
# define MACRO_ID_1000 1000
In main.c, I will input a string like MACRO1, MACRO2... I would like to write a function to output macro from input string
int func_string2macro (char* string)
{
...
return <macro_similar_to_string>;
}
For using : func_string2macro("MACRO1") then it will return MACRO_ID_1
I found that switch/case
can be solved this issue
But with a alot of macro (1000) then switch/case method is not good.
Anyone can support me?