Passing an array to a function, preferred way?
Is there a preferred or standard method for passing an array to a function as a parameter? First day of Advanced C++ today at college and we're working on some homework and the teacher wasn't much help. Our segment was to pass an array of integers to a function, and average them. Setting up the function I noticed that these both work:
I understand that they both point to the address for the array, but was wondering if there's a preferred or standard way to do this. I know there's something similar to how you define things as NULL in the new c++11, so was just looking for the right way to learn. :D
int avgNums(int* array, int n) // Pass pointer to array address
int avgNums(int array, int n) // Pass array address