0

Passing reference of an array

I want to pass an array to a function, and whatever edits I make to it in the function, must edit the value in original array , and not the copied. I tried : function_name(int &Array[]) but it gives error saying I'm trying to pass array of addresses. should I remove 'int' from this? function_name(int Array[]) works, but edits are done in new array, I don't want that, I want original array to change. I'm pretty new to programming, so any help is appreciated. Thanks.

8th Aug 2017, 2:21 AM
Rohan Hirekerur
Rohan Hirekerur - avatar
1 Answer
+ 2
ÂżWhat programing language? In C++ you can do this https://code.sololearn.com/cZEW5GO7hFTI/?ref=app When you pass a pointer as argument to a function, you simply give the address of the variable in the memory. So when you modify the value of the cell of the array, you edit the value under the address given to the function.
8th Aug 2017, 2:58 AM
Oscar Albornoz
Oscar Albornoz - avatar