I\'m new to C and I have a doubt.
Since C functions create local copies of it\'s arguments, I\'m wondering why the following code works as expected:
In the first code, you are passing the address of the array pointing to the top element in the array. So, when you modify the value in the function and return to the main function you are still accessing the same array which is in the same address. This is called pass by reference.
However, in the second case, the value of the integer is copied from the main function to the called function. In other words, the two integers are in different address in the memory. So modifying one does not modify the other.