Next Previous Contents

3.95 getopt

Function

Parse command line options.

Header

unistd.h

Declaration

int __fastcall__ getopt (int argc, char* const* argv, const char* optstring);

Description

The function parses command line arguments, argc and argv are the argument count and array passed to main. optstring is a string that contains command line option characters. If a character in optstring is followed by a colon, the option requires an argument. An option on the command line is recognized if it is one of the option characters preceeded by a '-'. getopt must be called repeatedly. It will return each option character found on the command line and EOF (-1) if there is no other option. An option argument is placed in optarg, the index of the next element on the command line to be processed is placed in optind.

Limits

  • The implementation will not reorder options. A non option on the command line will terminate option processing. All remaining arguments are not recognized as options, even if the start with a '-' character.
  • The function is only available as fastcall function, so it may only be used in presence of a prototype.

Availability

POSIX.2

Example

None.


Next Previous Contents