hi!
I have a problem with argv input parameter. I have 5 input parameters. But sometime I only need four of them (first, second, fourth and fifth). How can I exclude the third parameter?
Printable View
hi!
I have a problem with argv input parameter. I have 5 input parameters. But sometime I only need four of them (first, second, fourth and fifth). How can I exclude the third parameter?
I'm assuming you're using a loop to access them:
Code:int a;
for(a = 0; a < argc; a = ( ++a == 2 ? ++a : a ) ) {
}
Does your compiler have getopt() ? It's a useful function for accessing command line args. If you don't have it, you may be able to find the source on the web. (There are examples of its use on the forums here)
Alternatively, check each command line options manually yourself. It's best to adopt an approach that means invoking your program something like this:
>myprog.exe -aONE -bTWO -c
then you can go:
>myprog.exe -aONE -c