title: getopt_long() option with optional argument
body: <p>I am trying to create a option with an optional argument using getopt_long(). </p>
  
  <p>Here is my code:
  </p>
  
  <pre><code>static struct option long_options[] = {
     {"help",   no_argument,      NULL, 'h'},
     {"debug",  no_argument,      NULL, 'd'},
     {"config", optional_argument, NULL, 'c'},
     {NULL, 0, NULL, 0}
  };
  
  while ((ch = getopt_long(argc, argv, "hdc::", long_options, NULL)) != -1) {
          // check to see if a single character or long option came through
          switch (ch) {
              case 'h':
                  opt.help = true;
                  break;
              case 'd':
                  opt.debug = true;
                  break;
              case 'c':
                  printf("C-Option: %s\n", optarg);
                  if (optarg != NULL) {
                      opt.configFile = optarg;
                  }
                  break;
          }
      }
  </code></pre>
  
  <p>I am trying to make the argument for <code>-c</code> optional so you can run the program with these options:</p>
  
  <p><code>-c test.cfg</code> --> <code>optarg = "test.cfg"</code></p>
  
  <p><code>-c</code> --> <code>optarg = null</code></p>
  
  <p>If I set <code>c::</code> than <code>optarg</code> is always <code>null</code>.</p>
  
  <p>If I set <code>c:</code> than I get an error: <code>option requires an argument -- 'c'</code></p>
  
  <p>What did I wrong? Is there any other options I can set?</p>