Reputation: 147
Folks, I went over example of using get_opt_long here: https://linux.die.net/man/3/getopt_long_only And I am still confuse on how to utilized in my case. I have multiple options in my case.
-Aa => ask for all
-As => ask for stats
-Af => ask for file
-seed => pass seed
-num => repeat times
I can get -seed and -num to work, but not sure how to incorporate -Ap, -Ax -Af
here is my option struct:
enter code here
{"seed" , required_argument , NULL , 's'} ,
{"num" , required_argument , NULL , 'n'} ,
{"ask_all" , no_argument , NULL , 'a'} ,
{"ask_stat" , no_argument , NULL , 't'} ,
{NULL , 0 , NULL , 0}
also, how can I use -Ap, -As as command line argument. I am force to use unic character for all my options.
my while block has
case 's':
seed = atoi(optarg);
break;
case 'n':
num = atoi(num);
case 'a':
ask->all = true;
break;
Thanks
Upvotes: 0
Views: 47
Reputation: 409166
Two possible solutions:
"Aa"
, "As"
and "Af"
'A'
which takes a required argument that is the 'a'
, 's'
or 'f'
characterUpvotes: 1