I am currently studying C++ using Accelerated C++ by Koenig and i have a few troubles with the pointer to the initial array of pointers. It says in the book that the following code
int main(int argc, char** argv)
{
// if there are arguments, write them
if (argc > 1) {
int i; // declare i outside the for because we need it after the loop finishes
for (i = 1; i < argc-1; ++i)
// write all but the last entry and a space
cout << argv[i] << " ";
// argv[i] is a char*
cout << argv[i] << endl;
}
return 0;
}
when ran with "Hello, world" arguments will produce Hello World but if argv
is a pointer to an array of pointers then shouldn't argv[i]
be a pointer to an array of char
which output is a memory address instead of the array itself ?