尝试声明字符串数组时C语言错误

时间:2018-10-20 08:27:20

标签: c arrays compiler-errors declaration declare

我正在尝试使用C语言声明此字符串数组(或2d字符数组,我认为是),但编译器提示给我错误:“ [[Error]数组类型的元素类型不完整”

char division[][]={"Northeast Division","Northwest Division","Southeast Division","Southwest Division"};

我在做什么错了?

2 个答案:

答案 0 :(得分:1)

您必须指定字符串的最大长度。这应该可以解决您的问题

char division[][25]={"Northeast Division","Northwest Division","Southeast Division","Southwest Division"};

答案 1 :(得分:0)

您可以这样声明:

char *division[]={"Northeast Division","Northwest Division","Southeast Division","Southwest Division"};