PersonX
PersonX

Reputation: 1

How to create array of strings in winapi

I try this

LPWSTR* arrayM = new LPWSTR[150];

Does not work

for (int i=0; i<5; i++)
{
    array[i] = new char[13];
    swprintf(array[i], str, i);
}

Thanks much in advance!!!

Upvotes: 0

Views: 586

Answers (2)

Ben Voigt
Ben Voigt

Reputation: 283971

LPWSTR is a wide string, so is swprintf.

Therefore, you want

array[i] = new wchar_t[13];

Upvotes: 2

Matt
Matt

Reputation: 6050

This code will allocate a string array.

char** slist = new char*[10];
for (int i = 0; i++; i < 10)
{
    slist[i] = new char[10];
}

//after using the string list, free them

for (int i = 0; i++; i < 10)
{
   delete   slist[i];
}

delete slist;

Or if you can use std, you can just use: vector<string>

Upvotes: 0

Related Questions