title: Mandatory parameter getopt in C
body: <p>I have this piece of code in C </p>
  
  <pre><code>while((i = getopt(argc, argv, ":p:h:s:n:l:f:SLNF")) != -1)
      switch(i){
          case 'p': printf("Porta obbligatoria\n");
                    break;
          case 'h': printf("hostname\n");
                    break;
          case 's': printf("Surname\n");
                    break;
          case 'n': printf("Name\n");
                    break;
          case 'l': printf("Login\n");
                    break;
          case 'f': printf("Faculty\n");
                    break;
          case 'S': printf("Print Surname\n");
                    break;
          case 'L': printf("Print Login\n");
                    break;
          case 'N': printf("Print First name\n");
                    break;
          case 'F': printf("Print Faculty\n");
                    break;
          case '?': printf("USAGE\n");
                    break;
          default: printf("USAGE default\n");
                    break;
  
  
      }
  
  
     return 0;
  }
  </code></pre>
  
  <p>How can I have only one mandatory parameter? In my case is p.</p>
  
  <p>For example:</p>
  
  <pre><code>./MyProgram -p 80 -h 127.0.0.1
  </code></pre>
  
  <p>Result ok.</p>
  
  <pre><code>./MyProgram -h 127.0.0.1
  </code></pre>
  
  <p>Error because missing -p</p>
  
  <p>Only -p. </p>
  
  <p>Thanks in advance.</p>