K&R says the following about command line arguments:
The first [command line argument] conventionally called
argc
(for argument count) is the number of command-line arguments the program was invoked with; the second (argv
, for argument vector) is a pointer to an array of character strings that contain the arguments, one per string.
As shown above, the second argument is described as a pointer to an array of strings. Just to clarify, is this saying that the second argument is a pointer to a single array that has multiple strings stored in it?
Wouldn't the syntax just be: main (int argc, char argv)
but the syntax is main (int argc, char *argv[])
The parameter syntax looks more like an array of pointers, where each element points to string constants or the first elements of strings in another array.
The loop construct to print what these pointers point at look more like what I just described:
for(i = 1; i < argc; i++)
printf("%s\n", argv[i])
Is the argument an array of pointers? If so, What do the elements actually point to? If it's not, what is the parameter?