Recently, I encountered a problem about using the address of an array when I need to pass it as a reference to another function in C++. For example:
void do_something(float * arr, int size) {
//Will do something about the arr
}
int main () {
float array[] = {1, 2, 3, 4};
do_something(array, 4); // this will work well
do_something(&array, 4); // this will cause error
return 0;
}
But when I try to print out both array and &array, they are the same. Do you guys know what is the reason for this?