Skip to content

Instantly share code, notes, and snippets.

@cbarrett
Created November 25, 2013 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save cbarrett/7647270 to your computer and use it in GitHub Desktop.
Save cbarrett/7647270 to your computer and use it in GitHub Desktop.
/* Let's say you want to list all of the options to your program as an enum */
enum Option {
OptionFoo,
OptionBar,
CountOfOption
}
/* You want to write a procedure to generate a help message for your program. Here's one way: */
for (int option = 0; i < CountOfOption; i++) {
switch (option) {
case OptionFoo:
/* print foo usage */
break;
case OptionBar:
/* print bar usage */
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment