struct keyword and getopt_long

The  getopt() function parses the command-line arguments.  Its
arguments argc and argv are the argument count and
array as passed to the main() function on program invocation.
An element of argv that starts with  '-'  (and  is not  exactly
"-" or "--") is an option element.  The characters of this
element (aside from the initial '-') are option characters.
If getopt() is called repeatedly, it returns successively each
of the option characters  from each of the option elements.
longopts is a pointer to the first element of an array of struct option
declared in <getopt.h> as

           struct option {
               const char *name;
               int         has_arg;
               int        *flag;
               int         val;
           };

Example Code


static const struct option long_options[] =
{
{"domain", no_argument, 0, 'd'},
{"boot", no_argument, 0, 'b'},
{"file", required_argument, 0, 'F'},
{"fqdn", no_argument, 0, 'f'},
{"all-fqdns", no_argument, 0, 'A'},
{"help", no_argument, 0, 'h'},
{"long", no_argument, 0, 'f'},
{"short", no_argument, 0, 's'},
{"version", no_argument, 0, 'V'},
{"verbose", no_argument, 0, 'v'},
{"alias", no_argument, 0, 'a'},
{"ip-address", no_argument, 0, 'i'},
{"all-ip-addresses", no_argument, 0, 'I'},
{"nis", no_argument, 0, 'y'},
{"yp", no_argument, 0, 'y'},
{0, 0, 0, 0}
};