I need to resize copy an array as fast as possible. Is it a good way, or there are some dangers I cannot see?
(Lets assume that new size is greater than previous).
int N=SomeValue, NewSize=SomeValue; int *array=new int[N]; //making a temporary array: int *tmp=new int[NewSize]; for (int i=0;i<N;i++) tmp[i]=array[i]; delete array; array=tmp;
Or do I need to allocate array again and copy it from tmp to array and then delete tmp?
Will that work fine?
Thanks on advance for help :]