Hello all, I'm having trouble with getopt(3c) scanning in characters from command line. Specifically I want to see if two occurrences of the same character are present within the argument.
So for example ./program -abcdd where dd occurs twice.
Currently, I have the scanning as:
Code:
int x = 0;
for (;;)
{
int option = getopt (argc, argv, "ab:cd");
if (option == EOF) break;
switch (option)
{
case 'a': do something;
break;
case 'b': do something;
break;
case 'c': do something;
break;
case 'd': x++;
break;
default : exit;
}
}
My logic is that if x occurs twice, then it'll be incremented twice and i can use if ( x==1) or if ( x==2). But this doesn't seem to be working.