how to clear a 2d array in c++ code example
Example 1: delete 2d dynamic array c++
for (int i = 0; i < numRows; i++) {
delete [] world[i];
// world[i] = 0; // <- don't have to do this
}
delete [] world; // <- because they won't exist anymore after this
world = 0;
Example 2: how to make a n*n 2d dynamic array in c++
int** a = new int*[rowCount];
for(int i = 0; i < rowCount; ++i)
a[i] = new int[colCount];