Possible Duplicate:
Easy way to use variables of enum types as string in C?
Is there any elegant way to convert a user input string to an ENUM value is straight C, besides the manual way.
A simplified example of calling a function that takes an ENUM as an argument:
enum = {MONDAY,TUESDAY,WEDNESDAY};
...
//Get user to enter a day of the week from command line
...
//Set the work day according to user input
if (strcmp(user_input,"MONDAY")==0){
SET_WORK_DAY(MONDAY);
} else if (strcmp(user_input,"TUESDAY")==0){
SET_WORK_DAY(TUESDAY);
}
...
Thanks