简体   繁体   中英

Error with initializing a 2d wide char array?

I'm trying to do a 2d wchar_t array initialization using that code:

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:

{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][]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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