+ 1

Can arrary be copied using assignment operator?If possible how?

Condition the is you have two array let a[] and c[] and a[] have some values stored and you should copy those value in c[] without loop.

15th Sep 2019, 3:46 AM
Sagar Chhetri
Sagar Chhetri - avatar
4 Answers
+ 2
#include <algorithm> #include <iterator> #define arr_size 10 some_type src[arr_size]; // ... some_type dest[arr_size]; std::copy(std::begin(src), std::end(src), std::begin(dest));
15th Sep 2019, 7:36 AM
Aaron Eberhardt
Aaron Eberhardt - avatar
15th Sep 2019, 7:36 AM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 2
Arrays are containers of multiple data, I think it will be hard (or maybe impossible) to copy the content of one array to another without looping over each element of the array : )
15th Sep 2019, 7:55 AM
Ipang
+ 2
Thank You all
16th Sep 2019, 12:33 PM
Sagar Chhetri
Sagar Chhetri - avatar