Title here
Summary here
zeroptr
in contrast has an int&
parameter, meaning that it takes an int
reference. The *iptr
code in the function body then dereferences the pointer from its memory address to the current value at that address. Assigning a value to a dereferenced pointer changes the value at the referenced address.
Here’s the main function to demonstrate the usage of the above functions:
zeroval
doesn’t change the i
in main
, but zeroptr
does because it has a reference to the memory address for that variable.
When run, the output will be:
Now that we understand how basic pointer operations work, let’s delve deeper into the language.