A pointer, formally called a “derived data type” defines where to get the value of a data variable. It itself, does not store the data but the memory location of the variable.

So, in short, it is a (derived)data type which points to the data of the variable but stores only the memory location of the variable.

The pointer uses theĀ deference(*)Ā operator & the reference/address(&) operator. Some of the stuff we can do using pointers is shown down there.. ;)

<span style="color: #ff6633;">int</span><span style="color: #663300; font-weight: bold;"> *</span>p1<span style="color: #663300; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">          /* all of these can be used
int* p2;                  to declare pointers */</span><span style="color: #ff6633;">
int</span><span style="color: #663300; font-weight: bold;">*</span>p3<span style="color: #663300; font-weight: bold;">;</span><span style="color: #ff6633;">

int</span><span style="color: #663300; font-weight: bold;"> *</span>ptr<span style="color: #663300; font-weight: bold;">,</span> a<span style="color: #663300; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">      //declared pointer and variable
</span>ptr<span style="color: #663300; font-weight: bold;">=&amp;</span>a<span style="color: #663300; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">           //pointer now contains the address of a
</span>
cout<span style="color: #663300; font-weight: bold;">&lt;&lt;</span>ptr<span style="color: #663300; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">        //gives the memory location of a
</span>cout<span style="color: #663300; font-weight: bold;">&lt;&lt;*</span>ptr<span style="color: #663300; font-weight: bold;">;</span><span style="color: #999999; font-style: italic;">       //gives the value stored at a</span>

It’s very important not to get confused between the &variable, pointer, and *pointer.

&variable is used to assign the pointer an address of the variable, pointer gives the memory location of the variable and *pointer gives the value of the variable.