-
What does argc and argv indicate in command-line arguments?
(Assuming: int main(int argc, char *argv[]) )
-
- argument control, argument vector
- argument count, argument variable
- argument count, argument vector
- argument control, argument variable
- None of these
Correct Option: C
The name of the variable argc stands for "argument count"; argc contains the number of arguments passed to the program. The name of the variable argv stands for "argument vector". A vector is a one-dimensional array, and argv is a one-dimensional array of strings. Each string is one of the arguments that was passed to the program.
For example, the command line
gcc -o myprog myprog.c
would result in the following values internal to GCC:
argc
4
argv[0]
gcc
argv[1]
-o
argv[2]
myprog
argv[3]
myprog.c