Home » C Programming » Command Line Arguments » Question
  1. What does argc and argv indicate in command-line arguments?
    (Assuming: int main(int argc, char *argv[]) )
    1. argument control, argument vector
    2. argument count, argument variable
    3. argument count, argument vector
    4. argument control, argument variable
    5. 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



Your comments will be displayed only after manual approval.