int **dpTable = new int* [iMatrixHeight + 1];
for (int i = 0; i < iMatrixHeight + 1; i++)
{
dpTable[i] = new int [iMatrixWidth + 1];
}
memset(dpTable, 0, (sizeof(int)) * (iMatrixHeight + 1)*(iMatrixWidth + 1));
I'm using operator new to allocate a two-dimensional array, but if I use memset to initialize the array, I got a segmentfault when I access the array later. Without the memset, it's ok.
Am I doing anything wrong? THX!
memsetto obliterate the entire sequence of pointers your for-loop just worked so hard to acquire. (and breaching the sequence in the process just to add salt to the wound).