void func() // some function
{
int ARR[20];
.....
func1(ARR); // Passing the address of the first element of the array
.....
}
I am also aware that there are three ways to receive arrays
void func1(int *A) //Receive the address via a pointer variable
or void func1(int A[]) //Receive the address with an unsized array
or void func1(int A[20]) //Receive the address with an array of a size
My question is that what is the difference between the three allowed types of array receiving ? I think that changes made via a pointer variable are permanent while in the case of others it's not but I'm not sure about this. Is it true or not ? Thanks ! ^_^
I'm aware that all the three are equivalent for receiving arrays.
Assume that the value of ARR[5] was 5 in the function func(). After that i passed the array to func1(). But if i try to access the array by doing *(A+5)=10 this will it affect the original array ARR[20] ? If yes then will the change also happen when i use A[] or A[20] ?
@Zephilinox: Thanks for that code and yeah I'm sorry. I'm just starting to learn and sought for advice before starting my project. I saw that in all the cases the original array is modified. I didn't think it would happen in the case of func2() and func()3 though. Thanks again !! :)