array of wchar_t

Nemesis picture Nemesis · Mar 14, 2011 · Viewed 9.4k times · Source

I would like to have an array of wchar_t's.

The following works:

char** stringArray;
int maxWords = 3;
stringArray = new char*[maxWords];
stringArray[0] = "I";
stringArray[1] = " Love ";
stringArray[2] = "C++"

but this does not

wchar_t ** wcAltFinalText;
wcAltFinalText = new wchar_t *[MAX_ALT_SOURCE];   // MAX_ALT_SOURCE = 4
wcAltFinalText[0] = L'\0';
wcAltFinalText[1] = L'\0';
wcAltFinalText[2] = L'\0';
wcAltFinalText[3] = L'\0';

I do not get any error but wcAltFinalText is a bad ptr

Any help and comments are much appreciated.

Answer

Naveen picture Naveen · Mar 14, 2011

You are using '' instead of "", so the assignment wcAltFinalText[0] = L'\0'; is equivalent to wcAltFinalText[0] = 0;