What is the difference between argc
and argv
?
a)
argc
is the count of arguments, argv
is an array of argumentsb)
argv
is the count of arguments, argc
is an array of argumentsc) Both are used to declare variables
d) Both are used to allocate memory
Answer:
a)
argc
is the count of arguments, argv
is an array of argumentsExplanation:
In C, argc
(argument count) is an integer that represents the number of command-line arguments passed to the program, including the program’s name. argv
(argument vector) is an array of strings where each string represents a command-line argument. The first element of argv
is the program’s name, and subsequent elements contain the arguments. Together, argc
and argv
allow a program to accept and process user input at runtime.
Understanding the difference between argc
and argv
is crucial for handling command-line arguments effectively in C programs.