title: Multiple integer arguments with getopt?
body: <p>What is the best way to handle multiple integer arguments while using getopt? I have to be able to enter something like this on the command line: <code>calc -a 100 50</code> and it will add up 100 and 50.</p>
  
  <pre><code>    while ((opt = getopt(argc, argv, "adms")) != -1)
      {
  
         value = atoi(argv[optind + 1]);
        printf("value : %d\n", value);
  
          switch (opt)
          {
          case 'a': aFlag = 1; num1 = atoi(argv[optind]);
                    sum = num1 + value;
                    printf("%d + %d =  %d\n" , num1, value, sum);
                    break;
          case 'd': dFlag = 1;
                    break;
          case 'm':  break;
          case 's':  break;
          default:
              fprintf(stderr, "%s: unknown option %c\n", argv[0], optopt);
  return 1;
          }
      }
  
       if (aFlag == 1)
          {
                    num1 = atoi(argv[optind]);
                    sum = num1 + value;
                    printf("%d + %d =  %d\n" , num1, value, sum);
          }
       if (dFlag == 1)
          {
                    num2 = atoi(argv[optind]);
                    sub = num2 / value;
                    printf("%d / %d =  %d\n" , num2, value, sum);
          }
  </code></pre>