How can I copy dynamic array like that: Copy all elements of array, but start in second array not from 0 index, but from first.
//We have array x, which have 5 elements, and array y, which have 6 elements;
y[1]=x[0];
y[2]=x[1];
//etc...
P.S. Don't want copy element by element, can I use in that way std::copy
or memcpy
??
EDIT: Is it more efficient way to reallocate an array than this?
int* arr = new int[20];
...
//wanna resize to 25?
int* temp = new int[25];
std::copy(arr, arr+20, temp);
delete [] arr;
arr = temp;
... //now arr has 25 elements
But without using vector or other stl objects.