Simple command line parsing I'm making a project that needs a simple cross-platform command-line parser. I made this. Hope you enjoy!
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;stdarg.h&gt;

#define __NUM_OF_ELEMENTS(ARR) (sizeof(ARR)/sizeof(ARR[0]))
#define __HAS_ARG(FLAGS, ARG) (FLAGS &amp; (1 &lt;&lt; ARG))


void panic(const char *fmt, ...){
    fprintf(stderr, &quot;error: &quot;);

    va_list arglist;
    va_start( arglist, fmt );
    vfprintf(stderr, fmt, arglist);
    va_end( arglist );

    exit(EXIT_FAILURE);
}

void help(const char * progName){
    char * whoami = 0;
    (whoami = strrchr(progName, '/')) ? ++whoami : (whoami = progName);
    printf(

           &quot;%s is intended to do blah\n&quot;
           &quot;Options:\n&quot;
           &quot; --help                Display This message\n&quot;
           &quot; --file [file name]    Input file to use\n&quot;,

    whoami);
    exit(EXIT_SUCCESS);
}

int main(int argc, char *argv[])
{
    if(argc == 1){
        help(argv[0]);
    }

    const char * args[] = {&quot;--help&quot;, &quot;--file&quot;, &quot;--2cool4scool&quot;};
    enum                  {HELP_ARG, FILE_ARG, TOO_COOL_FOR_SCHOOL_ARG};
    unsigned int flags = 0;

    //skip prog name
    for(unsigned int arg = 1, i = 0; arg &lt; argc; ++arg){
        for(i = 0; i &lt; (unsigned int)__NUM_OF_ELEMENTS(args); ++i){
            if(!strcmp(argv[arg], args[i])){
                flags |= 1 &lt;&lt; i;
                goto CMD_ARGUMENT_FOUND;
            }
        }


        //argument is not found / unkown arg
        panic(&quot;Argument '%s' not found\n&quot;, argv[arg]);


        CMD_ARGUMENT_FOUND:;
    }

    if(__HAS_ARG(flags, HELP_ARG)){
        help(argv[0]);
    }
    if(__HAS_ARG(flags, TOO_COOL_FOR_SCHOOL_ARG)){
        puts(&quot;Hell YA!&quot;);
    }

    return 0;
}
Since this is a single-translation-unit program, mark your panic and help as static.
About this:
(whoami = strrchr(progName, '/')) ? ++whoami : (whoami = progName);

&quot;Yikes&quot;. Generously we call this write-only code. Unroll it to
char *whoami = strrchr(progName, '/');
if (whoami)
    whoami++;
else
    whoami = progName;

In this loop, your i declaration should be moved down:
for(unsigned int arg = 1, i = 0; arg &lt; argc; ++arg){
    for(i = 0; i &lt; (unsigned int)__NUM_OF_ELEMENTS(args); ++i){

should be
for (unsigned int arg = 1; arg &lt; argc; ++arg) {
    for (int i = 0; i &lt; (unsigned int)__NUM_OF_ELEMENTS(args); ++i) {

to narrow its scope.
Don't use goto. Factor out a function where the double loop termination is done using a return.