2 dimensional dynamic arrays
C / C++ / MFC
2
Posts
2
Posters
0
Views
1
Watching
-
I am having problems building a 2 dimensional dynamic array. I built a one dimensional dynamic array, but I don't know were to start with a 2 dimensional. I cannot find any helpful documentation on it so far on it. Any comments?
int nRows = 6; int nCols = 3; int ** cp; // Allocate rows cp = new int *[ nRows ]; // Now allocate using a loop for ( int index = 0; index < nRows; index++ ) { cp[index] = new int [ nCols ]; } cp[5][0] = 1; cp[5][1] = 2;