一如既往,http://cdecl.org是您的朋友:
char * (*arr)[] - "声明arr作为指向char指针数组的指针"char *** arr - "声明arr作为指向指向char的指针的指针"这些都不一样.首先,第一个是不完整的类型(为了使用指向数组的指针,编译器需要知道数组大小).
你的目标并不完全清楚.我猜你真正要做的就是修改数组中的底层数据char *.如果是这样,那么你只需将指针传递给第一个元素:
void my_func(char **pointers) {
pointers[3] = NULL; // Modify an element in the array
}
char *array_of_pointers[10];
// The following two lines are equivalent
my_func(&array_of_pointers[0]);
my_func(array_of_pointers);
Run Code Online (Sandbox Code Playgroud)
如果你真的想传递一个指向数组的指针,那么这样的东西就可以了:
void my_func(char *(*ptr)[10]) {
(*ptr)[3] = NULL; // Modify an element in the array
}
char *array_of_pointers[10];
// Note how this is different to either of the calls in the first example
my_func(&array_of_pointers);
Run Code Online (Sandbox Code Playgroud)
有关数组和指针之间重要区别的更多信息,请参阅C FAQ的专用章节:http://c-faq.com/aryptr/index.html.