Is there any difference between
foo(int* arr) {}
and
foo(int arr[]){}
?
Thanks
Is there any difference between
foo(int* arr) {}
and
foo(int arr[]){}
?
Thanks
There is no difference for the C compiler. There is a difference for the programmer that reads the code though.
Here, arr is a pointer to an integer (possibly for returning the result from the function):
foo(int* arr) {}
Here, arr is a pointer to the first integer in an array (possibly for passing a list of numbers in and/or out of the function):
foo(int arr[]) {}
Also, specifying the return type of the function would help.
The semantic is the same, but for an external programmer, it is easier and immediate to understand: the second function takes an array as argument. It could not be as immediate for the first one.
You will have to dereference values to the first one...