1 2 3 4 5 6 7 8 9 10 11 12 13 | void fun1(char * str) {} void fun2(char ** str) {} //~ int main(int argc, char ** argv) int main(int argc, char * argv[]) { char str1[] = "Hello, Piggy!"; char str2[][4] = "Hello, Piggy!"; fun1(str1); fun2(str2); fun2(&str1); return 0; } |
上面的snippet有错误吗?有几个?你能找出来并说出原因吗?4、5两行有区别吗?想一下,然后看gcc给出的错误信息,
test.c: In function ‘main’: test.c:9: error: invalid initializer test.c:11: warning: passing argument 1 of ‘fun2’ from incompatible pointer type test.c:4: note: expected ‘char **’ but argument is of type ‘char (*)[4]’ test.c:12: warning: passing argument 1 of ‘fun2’ from incompatible pointer type test.c:4: note: expected ‘char **’ but argument is of type ‘char (*)[14]’

请问:
代码是怎么编辑成这个样子的?插件吗?如果是,是什么插件?
我用的是一个叫CodeBox的插件,WP的Extention里面有,你可以找下。
找到了。谢谢