You are accessing an array of strings . The []
represents the array and the char *
represents the string . This is necessary because the command line can pass several arguments, and all are strings .
In C there is no string with its own concept, it is usually represented by an array or pointer, the most common character.
So there are two distinct things, so it needs to be used this way.
In C it's rare, but there are those who make typedef string char *;
to use string
instead of char *
.
If it were
int main(int argc, string argv[])
Would you understand? It's the same thing.
Can not access without the pointer because there is only an array of characters and not an array of strings , which is expected. In fact you even have access, but it will not be what you expect. You have to use the right type for what you need.