Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's char* const argv[]?

Tags:

People also ask

What is int argc const char * argv []?

argc stands for argument count and argv stands for argument values. These are variables passed to the main function when it starts executing.

What does char * argv mean?

The declaration char *argv[] is an array (of undetermined size) of pointers to char , in other words an array of strings. And all arrays decays to pointers, and so you can use an array as a pointer (just like you can use a pointer as an array).

What is const char * const *?

const char* const says that the pointer can point to a constant char and value of int pointed by this pointer cannot be changed. And we cannot change the value of pointer as well it is now constant and it cannot point to another constant char.

Is argv a const?

argv[] isn't const. And it certainly isn't a (static) string literal since it's being created at runtime. You're declaring a char * pointer then assigning a string literal to it, which is by definition constant; the actual data is in read-only memory.


I'm studying linux C++ programing when I see

int execve(const char *path,
           char *const argv[],
           char *const envp[]);

I don't understand what is char *const argv[] . I know char *const foo is a const pointer to char. And const char *foo is a pointer to a const char. But what's char *const argv[]?

Is it an array of const pointers to char or an array of pointers to const char?

And I have a vector<string> now, how to convert it to char *const argv[]?