最近需要声明一个字符串数组,所以写下如下语句:
const char** directories = {"cricket_batting", "cricket_bowling", "croquet", "tennis_forehand", "tennis_serve", "volleyball_smash"};
但是,g++ 向我显示了错误:
error: scalar object ‘directories’ requires one element in initializer
所以我把声明改成这样:
const char* directories[] = {"cricket_batting", "cricket_bowling", "croquet", "tennis_forehand", "tennis_serve", "volleyball_smash"};
这一次,是对的。但我不能完全知道 和 之间的char**
区别char[]
。