Is there some library fucntion to swap the values in two dynamically allocated arrays.
Suppose i declare and initialize my arrays like:
int * a = new int[10];
int * b = new int[5];
for(int i = 0; i < 10; i++){
a[i] = i + 1; //stores a[10] = {1,2,3,4,5,6,7,8,9,10}
}
for(int i = 0; i < 5; i++){
b[i] = i + 1; //stores b[5] = {1,2,3,4,5}
}
swap(a,b);
And i expect the a to store: {1, 2, 3, 4, 5}
And array b should store: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}