+ 26
// Wrong declaration int** arr = new int[size_row][size_col] // Proper declaration int **arr = new int*[size_row]; for(int i = 0; i < size_row; ++i) { arr[i] = new int[size_col]; } // Proper clean up for(int i = 0; i < size_row; ++i) { delete [] arr[i]; } delete [] arr; for a thorough discussion see [https://stackoverflow.com/questions/936687/how-do-i-declare-a-2d-array-in-c-using-new]
23rd Sep 2017, 9:52 AM
Babak
Babak - avatar