c - How do you use optional and non optional arguments? -
I getopt to accept command-line arguments such as
./ How do i use What I am trying to do just now, the command line accepts logic, where there are some alternatives and nothing is there.
For example:
./program argv [1] argv [2] -a yes - not
After several alternative arguments, the option is probably a bad idea; If you can help it, do not design the command line syntax.
He said, you can parse getopt outside of your code, unless you see anything like an option ( argv Increasing and decreasing argc ). Then use getopt for the remaining command line from that point.
Pseudo Code:
For (; * argv; argc -, argv ++) {if (argv looks like an option) break; Process * argv somehow) process now with getopt (argc, argv, ...)
Comments
Post a Comment