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;
string** new_array = array;
for(int i=0; i<numRows; i++){
new_array = new string[coloumns]
if(i != n){ // <- if you want to delete nth row then
new_array[i] = array[i];
}
}
array = new_array; // <- now array excluding nth row is saved in this pointer.
// let's say we want to dynamically make int[Y][X]:
int** superevil = new int*[Y];
for(int i = 0; i < Y; ++i)
superevil[i] = new int[X];
// now we can do this:
superevil[2][3] = 1;
// but cleanup is just as ugly as allocation:
for(int i = 0; i < Y; ++i)
delete[] superevil[i];
delete[] superevil;
Code Example |
---|
Cpp :: qt messagebox |
Cpp :: c++ chrono |
Cpp :: qt qimage load from file |
Cpp :: temporary mobile number |
Cpp :: access last element in vector in c++ |
Cpp :: cuda extern __shared__ |
Cpp :: c++ random number generator |
Cpp :: distinct colors cses solution |
Cpp :: how to remove spaces from a string |
Cpp :: c++ remove space from string |
Cpp :: c++ string to double |
Cpp :: use c++17 g++ |
Cpp :: qt double en qstring |
Cpp :: quadratic problem solution c++ |
Cpp :: locate specific string letters c++ |
Cpp :: how to print fixed places after decimal point in c++ |
Cpp :: extends c++ |
Cpp :: c++ print number not in scientific notation |
Cpp :: lcm function c++ |
Cpp :: min element c++ |
Cpp :: C++ Program to Reverse an Integer |
Cpp :: c++ length of char* |
Cpp :: c++ case |
Cpp :: iterating in map/unordered map c++ |
Cpp :: c++ random number 0 to 1 |
Cpp :: how to make a list in c++ |
Cpp :: return array from function c++ |
Cpp :: max_element c++ |
Cpp :: double to int c++ |
Cpp :: vector reverse function in c++ |