我很好奇,为什么我不能传递char **给const char **函数?在传递char *给const char *函数的情况下,使用双指针执行它似乎不行.我认为添加常量总是可以的(但不能删除常量)但现在看来我错了.
Gcc编译器给我错误的错误:
note: expected ‘const char **’ but argument is of type ‘char **’
Run Code Online (Sandbox Code Playgroud)
这是代码片段:
int f(const char **a) { }
int main() {
char *a;
f(&a);
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?