getopt_long

Retrieves long arguments from a command line argument list.

Library:LibC
Classification:GNU
Service:General C Services

Syntax

  #include <getopt.h> 
   
  int getopt_long (
     int                    argc,
     char * const           argv[],
     const char            *optstring,
     const struct option   *longopts,
     int                   *longindex );
  

Parameters

argc

(IN) Specifies the number of elements in the argv parameter.

argv

(IN) Points to an array of options.

optstring

(IN) Points to which short options to accept. Each option is a single character.

longopts

(IN) Points to an array of option structures which specify which long options to accept. The last element in the array must be a zero filled option structure.

longindex

(OUT) Points to the index into the longopts array for the long option.

Return Values

When getopt_long has no more options to handle, it returns -1.

Remarks

The getopt_long_only function parses options passed with a single hyphen (-) as short options and options passed with two hyphens (--) as long options.

See Also