Search
 
SCRIPT & CODE EXAMPLE
 

CPP

resizing dynamic array c++

void resize() {
    size_t newSize = size * 2;
    int* newArr = new int[newSize];

    memcpy( newArr, arr, size * sizeof(int) );

    size = newSize;
    delete [] arr;
    arr = newArr;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: watermelon codeforces solution 
Cpp :: 3d array in c++ 
Cpp :: how to create a copy constructor for generic array class in c++ 
Cpp :: c++ make constructor fails if bad argument 
Cpp :: initialize a pair 
Cpp :: gestd::getline with wstring 
Cpp :: program to convert int to int array c++ 
Cpp :: certificate exe application 
Cpp :: qt messagebox 
Cpp :: temporary mobile number 
Cpp :: c++ split long code 
Cpp :: c++ uniform_real_distribution get same result 
Cpp :: how to remove spaces from a string 
Cpp :: vector of structs c++ 
Cpp :: qlabel font color 
Cpp :: arduino led code 
Cpp :: c++ loop pyramid 
Cpp :: c++ type of a variable 
Cpp :: how to get last element of set in c++ 
Cpp :: convert string into integer in c++ 
Cpp :: how to find size of int array in c++ 
Cpp :: Unsorted Linked list in c++ 
Cpp :: cpp bubble sort 
Cpp :: c++ length of char* 
Cpp :: c++ switch case break 
Cpp :: map in c++ sorted descending order 
Cpp :: C++ Volume of a Sphere 
Cpp :: flags for g++ compiler 
Cpp :: c++ create multidimensional vector 
Cpp :: overload stream extract cpp 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =