If and when you have an array (real one) you can use the sizeof(array)
trick, but note that if you refactor the code and push it somewhere where the array has decayed into a pointer (or if the memory was initially allocated in a pointer (malloc/new) you will need to pass a known size.
Ignoring the relative sizes of source and destination, that is, assuming that they are the same for the rest of the discussion, if you are using C++ I would recommend a metaprogramming trick that will give you a typesafe size count for arrays and will fail to compile if you try to use it with pointers:
template <typename T, int N>
inline int array_memory_size( T (&a)[N] ) { return N*sizeof(T); }
That way:
int main() {
int array[10];
int *ptr = array;
int orig[10] = { 0 };
memcpy( array, orig, array_memory_size(array) ); // ok
//memcpy( ptr, orig, array_memory_size(ptr) ); // compilation error
}
If at any time you refactor and the code moves to a place where the array has decayed (or you replace an static array for a dynamically allocated one) the compiler will tell you that you need to correct the size calculation.