Are these declarations different or do the produce the same result?
char * const *argv;
and
const char **argv;
Is there a difference or are both pointer to a pointer?
The background is that I was writing a C commandline shell and used this struct for a command:
struct command
{
char * const *argv;
};
The above struct was used to call exec
. Now when I looked at another question then the struct was different:
Connecting n commands with pipes in a shell?
In that question the struct to achieve the same is different.
They are totally different:
char *const *argv;
declares "a pointer to const pointer to char";
const char **argv;
declares "a pointer to pointer to const char";
Also, char **const argv;
declares "a const pointer to pointer to char".
To understand these declarations, try reading them "inside out": http://c-faq.com/decl/cdecl1.html