这两个指针声明有什么区别?
What is the difference between these two pointer declarations?
这些声明是不同的还是产生相同的结果?
char * const *argv;
和
const char **argv;
有区别还是都指向指针?
背景是我正在编写 C 命令行 shell 并将此结构用于命令:
struct command
{
char * const *argv;
};
以上结构用于调用exec
。现在,当我查看另一个问题时,结构有所不同:
Connecting n commands with pipes in a shell?
在那个问题中,实现相同的结构是不同的。
它们完全不同:
char *const *argv;
声明 "a pointer to const pointer to char";
const char **argv;
声明 "a pointer to pointer to const char";
此外,char **const argv;
声明 "a const pointer to pointer to char"。
要理解这些声明,请尝试阅读它们 "inside out":http://c-faq.com/decl/cdecl1.html
这些声明是不同的还是产生相同的结果?
char * const *argv;
和
const char **argv;
有区别还是都指向指针?
背景是我正在编写 C 命令行 shell 并将此结构用于命令:
struct command
{
char * const *argv;
};
以上结构用于调用exec
。现在,当我查看另一个问题时,结构有所不同:
Connecting n commands with pipes in a shell?
在那个问题中,实现相同的结构是不同的。
它们完全不同:
char *const *argv;
声明 "a pointer to const pointer to char";
const char **argv;
声明 "a pointer to pointer to const char";
此外,char **const argv;
声明 "a const pointer to pointer to char"。
要理解这些声明,请尝试阅读它们 "inside out":http://c-faq.com/decl/cdecl1.html