Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

Resize method in c++ for arrays

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

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

    size = newSize;
    delete [] arr;
    arr = newArr;
}
Source by www.cplusplus.com #
 
PREVIOUS NEXT
Tagged: #Resize #method #arrays
ADD COMMENT
Topic
Name
3+9 =