Parsing Flashcards
Where are command line arguments stored?
In the args array in main.
What is the built in GNU C++ agrument decoder?
getopt
What library is getopt stored in?
<unistd.h>
What are the 4 most common items in getopt?
- getind
- optarg
- optopt
- getopt
What is the getopt variable optind?
An int index that tells the user where the next peice of info is stored
What is the getopt variable optarg?
Set to the value of the next argument, if they exist.
What is the getopt variable optopt?
Stores the value for an invalid argument if a ‘-‘ is provided with an unspecified argument.
What is the getopt function getopt?
The function that takes argc, argv, and char * containing the arguments that you want to include in the environment.
What are the return values of getopt()?
- An int rpresenting the next char in the argv array.
- -1 if there are no more arguments
- ’?’ or if there is an unrecognized character.
How must the getopt function be used?
In a looped manner to access all of the arguments.
In the char * argument getopt() function, what does a “:” signify?
That an argument must be provided after this flag. Ex: ‘-f:’ means a file name is expected after.
What is the more advanced versiont of getopt?
getopt_long