title: when long option is given as argument to short option - getopt_long
body: <p>I was learning how to accept command line arguments using getopt_long function, I made 2 long options 'filename' (required arg) and 'clear' (no arg) and 2 short args 'a' (with arg) and 'b' (no arg) when i executed:</p>
  
  <pre><code>$ ./a.out -a --filename=test.txt
  </code></pre>
  
  <p>instead of showing 'a' has no arg it shows the optarg for 'a' is:
  --filename=text.txt and skips the filename long option
  Any work around for this?</p>
  
  <p>My code is:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;getopt.h&gt;
  
  using namespace std;
  
  
  
  int main(int argc, char* argv[]){
  
      static struct option long_options[] = {
          {"filename",1,0,0},
          {"clear",0,0,0},
          {NULL,0,0,0}
      };
  
      int op,option_index = 0;
      string filename;
      while((op = getopt_long(argc,argv,"a:b",long_options,&amp;option_index))!=-1){
          switch (op){
              case 0:
                  switch(option_index){
                      case 0:
                          filename = optarg;
                          cout&lt;&lt;filename&lt;&lt;endl;
                          break;
                      case 1:
                          cout&lt;&lt;"clear is yes\n";
                          break;
                      default:
                          cout&lt;&lt;"Please enter valid long option\n";
                          break;
                  }break;
              case 'a':
                  cout&lt;&lt;"a is set as "&lt;&lt;optarg&lt;&lt;endl;
                  //cout&lt;&lt;optarg&lt;&lt;endl;
                  break;
              case 'b':
                  cout&lt;&lt;"b is set"&lt;&lt;endl;
                      break;
              default:
                  cout&lt;&lt;"Please enter valid Arguments"&lt;&lt;endl;
                  break;
          }
      }
      cout&lt;&lt;"\n\n";
  
      return 0;
  }
  </code></pre>