GNU Info

Info Node: (libc.info)Parsing Program Arguments

(libc.info)Parsing Program Arguments


Prev: Argument Syntax Up: Program Arguments
Enter node , (file) or (file)node

Parsing Program Arguments
-------------------------

   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' (Note: Getopt) or
`argp_parse' (Note: 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.

Getopt
Parsing program options using `getopt'.
Argp
Parsing program options using `argp_parse'.
Suboptions
Some programs need more detailed options.
Suboptions Example
This shows how it could be done for `mount'.

automatically generated by info2www version 1.2.2.9