-2
You are passing variables by reference when using the &
, so it’s not passing a value, it’s passing the address where it has a value. You can read more about it at What is the meaning of the operator "&" (and commercial) in the C language?.
In the function definition you are receiving normal values with the type int
. When you call the function you pass an address, the value your function is receiving is the address of a variable, so when you manipulate the value is changing the address set there and nothing else, which will have an innocuous action.
If you need to pass an address you should receive an address. And to say that you have to use the type int *
(or another type of point to a value of another type), it may not be just the basic type, it has to be a pointer to the type.
It is not enough to change the parameter, you have to do this in all access to the variable because you want access to the value and not the address. Remember that this variable is always the address and is not what you want to manipulate, for example *lat
. Done this you change the value you want.
I would show with an example, but as the AP did not make it easy for us and I would have to type all the code for this, there will be only the explanation. The answers can’t be as good when the questions haven’t been asked better.
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).
– Maniero