What are pointers?

Answer:

Answer

A pointer is a programming tool that allows a value to be referenced. All data is allocated in memory and has a certain address attached to them. When you use a pointer, you are taking a value from an address called the reference. The original data is called the reference, and taking that value using a pointer is called dereferencing.


Example using Objective-C:

int anInt = 42; (anInt is stored in memory with the value of 42)
int *anIntPointer; (this is new datatype that wants to point to a certain address)
*anIntPointer = &anInt; (you are taking the pointer and dereferencing it to anInt. anytime you have a pointer [in this case denoted with an asterisk "*"], the reference will be noted with an ampersand "&")


Now there are also pointers to objects and structs that use an entirely different method, but same idea, the pointer grabs a referenced data value. This is especially valuable for referencing structures without having to reference every single member variable.
First answer by Harithaveni. Last edit by Diresage. Contributor trust: 0 [recommend contributor recommended]. Question popularity: 29 [recommend question].