title: how to parse command line arguments in C?
body: <p>I am trying to parse command line arguments in C. Currently, I am using <code>getopt</code> do the parse. I have something like this:</p>
  
  <pre><code>#include &lt;unistd.h&gt;
  
  int main(int argc, char ** argv)
  {
     while((c=getopt(argc, argv, "abf:")) != -1)
     {
       switch(c)
       {
          case 'a':
          break;
          case 'b':
          break;
          case 'f':
          puts(optarg);
          break;
          case ':':
          puts("oops");
          break;
          case '?'
          puts("wrong command");
          break;
       }
     }
  }
  </code></pre>
  
  <p>then need to use <code>./a.out -f</code>to run the program, and <code>-f</code> is the command element, but looks like <code>-f</code> must start with a <code>'-'</code>, if I do not want the command element starts with '-', i.e, using <code>./a.out f</code> instead of <code>./a.out -f</code>, how to achieve it? </p>
  
  <p>if <code>getopt</code> does not support parsing a command line in this way, are there any other library to use in C?</p>