Quote:
Originally Posted by Tom Line
I still don't get the reason behind wanting to use a pointer rather than just a variable.
|
Say you have a structure. It has a variable in it that you want to modify with a function. If you were to just pass the structure into the function, the compiler would pass a copy of the structure to the function, so any changes you did to the structure wouldn't change the original. This isn't the behavior you want. So instead, you pass a pointer to the structure to the function. That pointer is a number saying where the structure is in memory, so when the compiler makes a copy of the pointer to pass into the function, that still points to the correct place in memory. You can then modify the structure in your function, and it all works.
I can try to clarify later, if someone else doesn't beat me to it, if that was confusing.