Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ allocate and free dynamic 2d array

// allocate
int** matrix = new int*[rowCount];
for(int i = 0; i < rowCount; i++)
    matrix[i] = new int[colCount];

// free
for(int i = 0 ; i < rowCount; i++)
    delete[] matrix[i];	// delete array within matrix
delete[] matrix;	// delete actual matrix
Comment

PREVIOUS NEXT
Code Example
Cpp :: count a character in a string c++ 
Cpp :: how to print hello world in c++ 
Cpp :: initialize 2d vector as 0 
Cpp :: eosio multi index clear 
Cpp :: check if double is integer c++ 
Cpp :: bits/stdc++.h visual studio 
Cpp :: uri online judge 3145 solution in c++ 
Cpp :: how to fix class friendship errors in c++ 
Cpp :: c++ how to generate a random number in a range 
Cpp :: ue4 bind function to button clicked c++ 
Cpp :: c++ for loop 
Cpp :: c++ console color some digits 
Cpp :: how to make a sqlite3 object in cpp 
Cpp :: How to block window resize sfml c++ 
Cpp :: how to change certain number from set c++ 
Cpp :: convert whole string to uppercase c++ 
Cpp :: qstring get if empty 
Cpp :: remove value from vector c++ 
Cpp :: char vector to string c++ 
Cpp :: how to print with the bool value in cpp 
Cpp :: how to make crypto 
Cpp :: convert decimal to binary c++ 
Cpp :: replace komma with space C++ 
Cpp :: c++ map iterator 
Cpp :: qt popup window 
Cpp :: count word accurances in a string c++ 
Cpp :: character array to string c++ stl 
Cpp :: in c++ the default value of uninitialized array elements is 
Cpp :: copy a part of a vector in another in c++ 
Cpp :: c++ reading string 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =