In C++ say we have two arrays:
a[5] = {1,2,3,4,5};
b[5] = {5,4,3,2,1};
If we wanted to set, for instance, a equal to b, how can we achieve that without using a loop?
My thought is to use recursion, but I’m not exactly sure how.
Edit: Sorry, should have made it clear I don’t want to use the standard library functions (including memcpy which some of you have mentioned)
With recursion:
I don’t understand the need for recursion though, using
memcpy()instead is better.