please excuse my bad english,
let me clarify, here is an example,
this is our main :
main()
{
int a1 []= {1,2,3,4,5,6,7,8,9} ;
int size = sizeof(a1) /sizeof(a1[0]) ;
point (a1 , size);
return 0 ;
}
and this is the function:
void point(int a[] , int size)
{
int i ;
for (i = 0 ; i<size ; i++)
printf("%d\n", a[i])) ;
}
From my knowledge, when an array is passed as an argument to a function, we are actually sending a pointer to the first element to the array..
With that being said, how come the function "point"'s parameter is an ARRAY variable, NOT a POINTER variable...?
The reason I thought this was weird, so for example in main we pass int* to some function :
int* a = &b ;
point2(a) ;
The function:
void point2 (int a) // this would be invalid, it has to be int* a
{
.
.
}
We would have to specify that the function receives a pointer, How are arrays an exception?
PLEASE NOTE: I do understand that arrays decay to pointers; that's why my question never was "why can we send arrays as arguments, to functions that have pointers of that same type?". My question is, "How come even though arrays decay to POINTERS, its fine to keep the parameter of the function as an ARRAY?". Hope it is clear how this is different that the first question. Thank you!