Horje
copy array c++ Code Example
copy array c++
#include <algorithm>
#include <iterator>

const int arr_size = 10;
some_type src[arr_size];
// ...
some_type dest[arr_size];
std::copy(std::begin(src), std::end(src), std::begin(dest));
array copx c++
#include <algorithm> //Only needed for Option 1
#include <iostream>

using namespace std;

int main() {
  	//Option 1
    const int len{3};
    int arr1[len] = {1,2,3};
    int arr2[len]; //Will be the copy of arr1
    copy(begin(arr1), end(arr1), begin(arr2));
  
  	//Use the following, if you are not using namespace std;
    //std::copy(std::begin(arr), std::end(arr), std::begin(copy));
  
    //Option 2
    int arr3[len]; //Will be the copy of arr1
    for(int i = 0; i<len; ++i) {
      arr3[i] = arr1[3];
    }
    
    return 0; //exitcode
};




Cpp

Related
in c++ ++ how to write if without if Code Example in c++ ++ how to write if without if Code Example
convert vector into array c++ Code Example convert vector into array c++ Code Example
how to use decrement operator in c++ Code Example how to use decrement operator in c++ Code Example
c++ initialize array with all zeros Code Example c++ initialize array with all zeros Code Example
integer type validation c++ Code Example integer type validation c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9