title: Command line arguments: use of space between program argument, and the argument's argument
body: <p>Here, i have a program, which takes arguments (how surprising...). I want him to have several arguments, as:</p>
  
  <pre><code>./myprogram -f filename.txt -x -o
  </code></pre>
  
  <p>so i want main args with "-", and these arg shall accept an other arg, in the example, a filename.</p>
  
  <p>I have this structure, very simple:</p>
  
  <pre><code>int main(int argc, char *argv[])
  {
      printf("Program name: %s\n", argv[0]);
  
      while ((argc &gt; 1) &amp;&amp; (argv[1][0] == '-'))
      {
          switch (argv[1][1])
          {
              case 'f':
                  printf("%s\n",&amp;argv[1][3]);
                  break;
  
              case 'd':
                  printf("%s\n",&amp;argv[1][2]);
                  printf("%s\n",&amp;argv[1][2]);
                  break;
  
              default:
                  printf("Wrong Argument: %s\n", argv[1]);
                  usage();
          }
  
          ++argv;
          --argc;
      }
  
  
      return 0;
  }
  </code></pre>
  
  <p>As you can see, in case of -d, this prints what's following the argument, without space; here is a sample output:</p>
  
  <pre><code>./myprogram -dfilename
  Program name: myprogram
  filename
  filename
  </code></pre>
  
  <p>and with the -f parameter,</p>
  
  <pre><code>./myprogram -f filename
  Program name: myprogram
  ffilename
  </code></pre>
  
  <p>it prints twice the first letter, and i don't understand why.
  Could someone help?</p>