In the following function declaration, the first argument is a String, specifically, an array of chars, and the third argument is a pointer to an integer. Is the second argument a pointer to an array of chars? In other words, a pointer to a pointer? I find this after reading this answer to a related question: Difference between passing array and array pointer into function in C
void setup(char inputBuffer[], char *args[], int *background) {...}
In other words, is *args[] equivalent to **args?
Thanks a lot!
Yes, in passing arguments to a function, char *args[]
is equivalent to char **args
.
In the first argument, char inputBuffer[]
, the function actually receives not the whole char
array but only a pointer variable holding the address of its first element.
In the second argument, char *args[]
, similarly, the function receives not the whole array of pointers to char
s, but a pointer variable holding the address of the first element. In this case the element is itself a pointer. Therefore the function receives a pointer to a char
pointer, equivalent to char **args
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments