Hi. Just curious. When passing array pointers around functions is there a difference between the following lines of code? ...
// Function to which the array pointer is passed...
1 2 3
int myFunction(char *buffer){
// arbitrary code
}
// first way of passing an array pointer to the function...
1 2 3 4
int main(){
char myBuffer[1024];
int result = myFunction(myBuffer);
}
// second way of passing an array pointer to the function...
1 2 3 4
int main(){
char myBuffer[1024];
int result = myFunction(&myBuffer[0]);
}
I orginally believed that there was no difference, however in a recent project changing some code from method 1 to method 2 seemed to fix some problems I was having, but am unsure whether or not it was a coincidence or not :)
In that case there is no difference. I don't see how a change could have fixed anything in the program. If you use the debugger you'll see that the same address is passed in either way.