Previous: Program Argument Syntax Conventions, Up: Program Arguments [Contents][Index]
If the syntax for the command line arguments to your program is simple
enough, you can simply pick the arguments off from argv by hand.
But unless your program takes a fixed number of arguments, or all of the
arguments are interpreted in the same way (as file names, for example),
you are usually better off using
getopt (see Parsing program options using
argp_parse (see Parsing Program Options with Argp) to do the parsing.
getopt is more standard (the short-option only version of it is a
part of the POSIX standard), but using
argp_parse is often
easier, both for very simple and very complex option structures, because
it does more of the dirty work for you.