I'm confused on setting up a 2D unallocated pointer to an array without using a struct
.
This compiles in a 1D array:
wchar_t *sServerArray = new wchar_t [128]();
But this does not compile:
wchar_t *sServerArray = new wchar_t [16][128]();
I'm missing something simple I think! Can someone help?
A struct
would be something like this:
struct sServerArray
{
TCHAR *sName;
};
sServerArray *sGN = new sServerArray [128]();
Then allocate the memory:
for (INT i = 0; i<16; i++)
{
sGN[i].sName = (TCHAR*)calloc(16,sizeof(TCHAR));
}
I can do auto
, but do I also need to allocate memory for each of the 16 rows?