#include <iostream>
using namespace std;
int main() {
int arr[5];
arr[0]=33;
arr[1]=47;
arr[2]=59;
arr[3]=67;
arr[4]=98;
for(int i=0;i<5;i++){
cout<<arr[i]<<endl;
}
cout<<endl;
int two[5]=arr;
two[2]=590;
for(int i=0;i<5;i++){
cout<<two[i]<<endl;
}
return 0;
}
I was expecting the new array "two" point to the same address as "arr", but instead it gives following error:
array must be initialized with a brace-enclosed initializer
18 | int two[5]=arr;
| ^~~
I explored that I can use copy() from algorithm header for doing the task. I want to know about other approaches to the same problem.