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.
1 Respuesta
+ 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.