Parsing Flashcards

1
Q

Where are command line arguments stored?

A

In the args array in main.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the built in GNU C++ agrument decoder?

A

getopt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What library is getopt stored in?

A

<unistd.h>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the 4 most common items in getopt?

A
  • getind
  • optarg
  • optopt
  • getopt
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the getopt variable optind?

A

An int index that tells the user where the next peice of info is stored

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the getopt variable optarg?

A

Set to the value of the next argument, if they exist.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the getopt variable optopt?

A

Stores the value for an invalid argument if a ‘-‘ is provided with an unspecified argument.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the getopt function getopt?

A

The function that takes argc, argv, and char * containing the arguments that you want to include in the environment.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the return values of getopt()?

A
  • 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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How must the getopt function be used?

A

In a looped manner to access all of the arguments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

In the char * argument getopt() function, what does a “:” signify?

A

That an argument must be provided after this flag. Ex: ‘-f:’ means a file name is expected after.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the more advanced versiont of getopt?

A

getopt_long

How well did you know this?
1
Not at all
2
3
4
5
Perfectly