How to retrieve multi args for one option using getopt in libc ?
./a.out -t 42 -n toto titi tata -a address
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main(int ac, char **av)
{
int opt;
while ((opt = getopt(ac, av, "t:n:a:")) != -1) {
switch (opt) {
case 't':
printf("time = %s\n", optarg);
break;
case 'n':
/* HOW RETRIEVE HERE ALL OTHER NAME ?*/
printf("name = %s\n", optarg);
break;
case 'a':
printf("address = %s\n", optarg);
break;
default:
fprintf(stderr, "Usage : %s [-t time] [-a name1 name2 ...] [-s address]", av[0]);
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
}