Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ - char** argv vs. char* argv[]

What is the difference between char** argv and char* argv[]? in int main(int argc, char** argv) and int main(int argc, char* argv[])?

Are they the same? Especially that the first part does not have [].

like image 393
Simplicity Avatar asked Mar 04 '11 09:03

Simplicity


People also ask

What does char * argv [] mean in C?

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 does * argv [] mean?

What does int argc, char *argv[] mean in C/C++? CC++Server Side ProgrammingProgramming. argc stands for argument count and argv stands for argument values. These are variables passed to the main function when it starts executing. When we run a program we can give arguments to that program like − $ ./a.out hello.

What does int argc char * argv [] mean?

Command-line Arguments: main( int argc, char *argv[] ) Here argc means argument count and argument vector. The first argument is the number of parameters passed plus one to include the name of the program that was executed to get those process running.

What is the difference between char pointer and char array?

For the array, the total string is stored in the stack section, but for the pointer, the pointer variable is stored into stack section, and content is stored at code section. And the most important difference is that, we cannot edit the pointer type string.


1 Answers

They are entirely equivalent. char *argv[] must be read as array of pointers to char and an array argument is demoted to a pointer, so pointer to pointer to char, or char **.

This is the same in C.

like image 125
Fred Foo Avatar answered Sep 17 '22 22:09

Fred Foo