I have declared the following enum :
enum periods {one, five, ten, fifteen, thirty};
and now I want to pass it as a commandline argument
At a random guess, what you really want is something more like:
periods mp;
if (argc < 2) {
mp=one; // default value
} else if (strcmp(argv[1], "one")==0) {
mp=one;
} else if (strcmp(argv[1], "five")==0) {
mp=five;
} else if (strcmp(argv[1], "ten")==0) {
mp=ten;
} else if (strcmp(argv[1], "fifteen")==0) {
mp=fifteen;
} else if (strcmp(argv[1], "thirty")==0) {
mp=thirty;
} else {
fprintf(stderr, "I can't possibly comprehend periods = '%s'\n", argv[1]);
return -1;
}