Hi,
I'm trying to write a function that enlarges a dynamically allocated array, but I am having some trouble doing so. Here's my code:
void enlargeArray(int *oldArr, int arraySize)
{
//oldArr is a dynamically allocated array
int *newArr = new int[arraySize*2];
//copy the elements from oldArr into newArr
delete oldArr[];
oldArr = newArr;
}
However, although newArr gets created correctly, when I examine the contents of oldArr in my main function (where I call enlargeArray from), oldArr is unchanged. Does anyone have any tips for how to modify oldArr itself? Thank you.