array copx c 2b 2b

Solutions on MaxInterview for array copx c 2b 2b by the best coders in the world

showing results for - "array copx c 2b 2b"
Emanuele
07 Sep 2018
1#include <algorithm> //Only needed for Option 1
2#include <iostream>
3
4using namespace std;
5
6int main() {
7  	//Option 1
8    const int len{3};
9    int arr1[len] = {1,2,3};
10    int arr2[len]; //Will be the copy of arr1
11    copy(begin(arr1), end(arr1), begin(arr2));
12  
13  	//Use the following, if you are not using namespace std;
14    //std::copy(std::begin(arr), std::end(arr), std::begin(copy));
15  
16    //Option 2
17    int arr3[len]; //Will be the copy of arr1
18    for(int i = 0; i<len; ++i) {
19      arr3[i] = arr1[3];
20    }
21    
22    return 0; //exitcode
23};