Remember that the function “main” takes optional parameters, these being common:
ID: 666898 • Letter: R
Question
Remember that the function “main” takes optional parameters, these being common:
int main( int ac, char *av[] )
A.The variable “av” is a pointer to the command line, which can then be broken up with calls to “strtok”
B.The variable “av” has the name of the program plus the other words from the command line.
C. If there were no command line parameters, “av[0]” is NULL.
D.The value in “av[0]” is the first parameter after the program name that was typed on the command line.
E. The variable “ac” is the number of command line arguments minus one
Explanation / Answer
1. True, The variable “av” is a pointer to the command line, which can then be broken up with calls to “strtok”
for example ./run 1 2 3 4
av[0] = run; av[1] = 1; av[2] = 2; av[3] = 3; av[4] = 4;
2. True, The variable “av” has the name of the program plus the other words from the command line.
for example ./run 1 2 3 4
av[0] = run; av[1] = 1; av[2] = 2; av[3] = 3; av[4] = 4;
3. False, If there were no command line parameters, “av[0]” is NULL
then av[0] is name of the program
4. True, The value in “av[0]” is the first parameter after the program name that was typed on the command line
for example ./run 1 2 3 4
av[0] = run
5. False, The variable “ac” is the number of command line arguments minus one
it is length of command line arguments.