vendredi 18 août 2017

Understanding get_opt

I am trying to figure this out I have not been able to call a small program properly with the following options:

static struct option long_options[] = {
    {"t", 2, 0, 0 },
    {"m", 2, 0, 1 },
    {0,0,0,0}
  };

  while (1) {
    int oi = 0;
    int c =  getopt_long( argc, argv, "", long_options, &oi );
    if ( c == -1) break;
    switch( c ) {
    case 0:
       tenant = atoi(optarg);
      break;
    case 1:
       mantle = atoi(optarg);
    default:
      return -1;
    }
  }

How am I supposed to call this program? I have tried

./myprogram -t 10 and ./myprogram --t 10

Aucun commentaire:

Enregistrer un commentaire