option

Contains information about a long option.

Service:General C Services

Syntax

  #include <getopt.h>
  
  struct option
  {
     const char   *name;
     int           has_arg;
     int          *flag;
     int           val;
  };
  

Fields

name

Points to the name of the option which is a string.

has_arg

Specifies whether the option takes an argument with one of the following flags:

Flag

Value

Description

no_argument

0

The option does not take an argument.

required_argument

1

The option requires an argument.

optional_argument

2

The option has an optional argument.

flag

Points to the flag name of the option argument or to a NULL pointer.

val

Specifies to the value of the argument.