What is a Pointer?

Taylor Emma
1 Min Read
Disclosure: This website may contain affiliate links, which means I may earn a commission if you click on the link and make a purchase. I only recommend products or services that I personally use and believe will add value to my readers. Your support is appreciated!

In simple words, a pointer is an address. It is a derived data type that stores the memory address. A pointer can also be used to refer another pointer, function. A pointer can be incremented/ decremented, i.e., to point to the next/ previous memory location.

How does Pointer Work?

If we declare a variable v of type int, v will actually store a value.

v is equal to zero now.

However, each variable, apart from value, also has its address (or, simply put, where it is located in the memory). The address can be retrieved by putting an ampersand (&) before the variable name.

If you print the address of a variable on the screen, it will look like a totally random number (moreover, it can be different from run to run).

Let’s try this in practice.

The output of this program is -480613588.

Now, what is a pointer? Instead of storing a value, a pointer will y store the address of a variable.

Int *y = &v;

VARIABLEPOINTER
value stored in a named storage/memory addressvariable that points to the storage/memory address of another variable
Share This Article
A senior editor for The Mars that left the company to join the team of SenseCentral as a news editor and content creator. An artist by nature who enjoys video games, guitars, action figures, cooking, painting, drawing and good music.
Leave a review