Help with implementing a function to change size of dynamic array
- by iRobot
I'm trying to write a function that will change the size of a dynamic array to a new size. In my header file, I have:
Image **images; //pointer to a dynamic array of image pointers
int maximum; //size
I want to do this by allocating a new array and copying the values over without changing their indices. If there are non-null pointers outside the range newmax, then we cant do this. So heres what I have:
There are no compilation or runtime errors. However, I find that the new array isnt getting sized right. When I run the following test case:
I should get an index out of bounds error, but instead the system lets it slide. Can anyone see the mistake? I've looked for hours but cant find anything.