+ 7
Pointer
Explain to me pointers in a nutshell (/Friendliest way to understand)
4 Respuestas
+ 10
pointer: points to variables place in memory.
there are two parts to pointers.
& - address-of operator : gets memory address
* - Dereference operator : accesses the variable the pointer 'points' too
int var = 5
ptr = &var // puts the memory address of var in ptr
value = *ptr // puts the value pointed to by ptr into value.. (5)
not the clearest. by i hope it helps 😊
+ 8
Oh now I get it, Thanks @jay :D
Its like reading someones memory and trying to copy what he's doing! :D Awwwsumm
+ 7
@jay Now thats a very cool thing to do Thank you very much, helped alot to learn pointers as it is important in Rust
+ 6
You can also edit what the person is thinking
*ptr = 6
would change var from 5 to 6