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));
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
};
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us