\C\Advanced
cmd_line_options.c
#include#include #define OPTIONS_LIST {"-?\0","/?\0","-h\0"} #define NUM_OPTIONS 3 int main(int argc, char **argv) { int i = 0, j = 0; char *cOpts[] = OPTIONS_LIST; while(i++ < argc - 1) { while(j < NUM_OPTIONS) { if(strcmp(cOpts[j], argv[i]) == 0) { if(strcmp(cOpts[j], "-?") == 0) { puts("We got the -? option"); break; } if(strcmp(cOpts[j], "/?") == 0) { puts("We got the /? option"); break; } if(strcmp(cOpts[j], "-h") == 0) { puts("We got the -h option"); break; } } j++; } j = 0; } return 0; }