Skip to content

Instantly share code, notes, and snippets.

@cbarrett
Created November 25, 2013 19:30

Revisions

  1. cbarrett created this gist Nov 25, 2013.
    20 changes: 20 additions & 0 deletions gistfile1.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    /* 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;
    }
    }