Search
 
SCRIPT & CODE EXAMPLE
 

CPP

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;
Comment

delete specific row from dynamic 2d array c++

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.
Comment

new and delete 2D array

// 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;
Comment

PREVIOUS NEXT
Code Example
Cpp ::  
Cpp :: prints all the keys and values in a map c++ 
Cpp :: c++ default array value not null 
Cpp :: how to output to console c++ 
Cpp :: stl for sorting in c++ 
:: read variable to file cpp 
:: min heap in c++ 
Cpp :: c++ check open processes 
Cpp :: cannot find -lsqlite3 C++ compiler error 
Cpp :: vector of structs c++ 
Cpp :: finding no of unique characters in a string c++ 
Cpp :: cpp random number in range 
Cpp :: c++ vector add only unique elements 
Cpp :: macro c++ 
Cpp :: c++ check if string contains non alphanumeric 
Cpp :: c++ cli convert string to string^ 
Cpp :: tarray ue4 c++ 
Cpp :: c++ user input 
Cpp :: kruskal in c++ 
Cpp :: std distance c++ 
Cpp :: delete last char of string c++ 
Cpp :: cpp macro 
Cpp :: chrono start time in c++ 
:: map in c++ sorted descending order 
:: arguments to a class instance c++ 
Cpp :: height of bst cpp 
Cpp :: c++ random number between 0 and 1 
Cpp :: how to store pair in min heap in c++ 
Cpp :: restting a queue stl 
Cpp :: check if character in string c++ 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =