Consider the following C/C++ functions:
void print_array_1(int arr[4]) {
for (int i = 0; i < 4; ++i) {
std::cout << arr[i] << std::endl;
}
}
void print_array_2(int arr[]) {
for (int i = 0; i < 4; ++i) {
std::cout << arr[i] << std::endl;
}
}
When passing in a four element array into each functions, they both do the same thing.
Is there any real difference? arr
is just a pointer to a chunk of memory, so it seems like they should be equivalent.