I am trying to get options via getopt.
I`ve run the program via the command line:
test.exe -ja 1:2 -ja 3:4
My code have following:
int c;
while ((c = getopt (argc, argv, "j:")) != -1) {
switch (c) {
case 'j': {
printf("Find j\n");
if (optarg[0] == 'a') {
printf("Find a\n");
}
break;
}
}
}
The problem is that case 'j' triggered only once, not twice. What should i change to read every -ja option?