简体   繁体   English

初始化2d宽字符数组时出错?

[英]Error with initializing a 2d wide char array?

I'm trying to do a 2d wchar_t array initialization using that code: 我正在尝试使用该代码进行2d wchar_t数组初始化:

const wchar_t* e[6][]={
    { L"ç", L"$^^" },
    { L"ç"},
    { L"ç", L"$^^" },
    { L"ç", L"$^^" },
    { L"ç", L"$^^" },
    { L"ç", L"$^^" }
};

but I get an error when compiling: 但是编译时出现错误:

array type has incomplete element type

so what's wrong and what to do to solve that problem? 那么怎么了?怎么解决这个问题呢?

The only optional length when declaring an array is the first one, so in your case you need to specify the second one: 声明数组时,唯一的可选长度是第一个,因此在您的情况下,您需要指定第二个:

const wchar_t *e[][2] ;

Moreover be carefull that the array in second position is filled with NULL value at the end: 此外,请注意,第二个位置的数组最后会填充NULL值:

{L"ç"} 
// is in fact
{L"ç", NULL}

The way you are declaring the array is wrong... You should be doing... 您声明数组错误的方式...您应该这样做...

const wchar_t* e[][6] instead of const wchar_t* e[6][] const wchar_t* e[][6]而不是const wchar_t* e[6][]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM