The easiest way is to encapsulate your array int a container and have your function take the container by value (and you can template the function to make it use that definition for all container types). I'd suggest using boost::array< int, 5 > (boost.org) if you are sure that you always need an array of 5 elements, or you can use std::vector (but I wouldn't recommend it as it forces dynamic memory allocation unless you wanna have some fun with allocators).
Originally posted by manwhoonlyeats
What i'm wondering is if there is an easy way to pass a copy of an array to a function. in the following program i pass the address of an array of numbers, a, to the change function. But what i really want to do is pass a copy so that the function change can not change a. How can i do this?