#include <algorithm>
int main()
{
// set up arr1
int *arr1 = new int[5]; // make array of 5 ints and set arr1 to point to it
// add data to arr1
arr1[0] = 1;
arr1[1] = 2;
arr1[2] = 3;
arr1[3] = 4;
arr1[4] = 5;
// set up arr2
int *arr2 = new int[10]; // make array of 10 ints and set arr2 to point to it
// arr2 = arr1; // lose the array of 10 ints forever and set arr2 to point to array of 5 ints
std::copy(arr1, arr1+5, arr2); // copy the contents of the array of 5 ints into the array of 10 ints
// add more values
arr2[5] = 6;
arr2[6] = 7;
arr2[7] = 8;
arr2[8] = 9;
arr2[9] = 10;
delete[] arr1;
delete[] arr2;
}
I2luY2x1ZGUgIDxhbGdvcml0aG0+CmludCBtYWluKCkKewogICAgLy8gc2V0IHVwIGFycjEKICAgIGludCAqYXJyMSA9IG5ldyBpbnRbNV07IC8vIG1ha2UgYXJyYXkgb2YgNSBpbnRzIGFuZCBzZXQgYXJyMSB0byBwb2ludCB0byBpdAoKICAgIC8vIGFkZCBkYXRhIHRvIGFycjEKICAgIGFycjFbMF0gPSAxOwogICAgYXJyMVsxXSA9IDI7CiAgICBhcnIxWzJdID0gMzsKICAgIGFycjFbM10gPSA0OwogICAgYXJyMVs0XSA9IDU7CgogICAgLy8gc2V0IHVwIGFycjIKICAgIGludCAqYXJyMiA9IG5ldyBpbnRbMTBdOyAvLyBtYWtlIGFycmF5IG9mIDEwIGludHMgYW5kIHNldCBhcnIyIHRvIHBvaW50IHRvIGl0CiAgICAvLyBhcnIyID0gYXJyMTsgLy8gbG9zZSB0aGUgYXJyYXkgb2YgMTAgaW50cyBmb3JldmVyIGFuZCBzZXQgYXJyMiB0byBwb2ludCB0byBhcnJheSBvZiA1IGludHMKICAgIHN0ZDo6Y29weShhcnIxLCBhcnIxKzUsIGFycjIpOyAvLyBjb3B5IHRoZSBjb250ZW50cyBvZiB0aGUgYXJyYXkgb2YgNSBpbnRzIGludG8gdGhlIGFycmF5IG9mIDEwIGludHMKCiAgICAvLyBhZGQgbW9yZSB2YWx1ZXMKICAgIGFycjJbNV0gPSA2OwogICAgYXJyMls2XSA9IDc7CiAgICBhcnIyWzddID0gODsKICAgIGFycjJbOF0gPSA5OwogICAgYXJyMls5XSA9IDEwOwoKICAgIGRlbGV0ZVtdIGFycjE7CiAgICBkZWxldGVbXSBhcnIyOwp9Cg==