I know that Java has a function System.arraycopy();
to copy an array. I was wondering if there is a function in C or C++ to copy an array. I was only able to find implementations to copy an array by using for
loops, pointers, etc. But is there a library function that I can use to copy an array?
Since C++11, you can copy arrays directly with std::array
:
#include <array>
std::array<int, 4> A = {10, 20, 30, 40};
std::array<int, 4> B = A; // Copy array A into array B