My beginner level understanding of a pointer

I do not know what a pointer is, and I am generally confused from the lesson, but I believe it acts reminescent to that of a variable and the name of that variable. Fetching information from the memory and bringing it into your code? That is my current understanding, would love if someone cleared the air and helped me understand if that is wrong.

Pointer stores an address of the variable, e.g. you have boolean variable that has a value of 1 and it’s stored in memory at address 5, so pointer to that variable would have a value of 5

pointers are like a desktop shortcut to a directory in your machine



People above gave you good answers about what pointer is. I want to add one thing: why pointers? In gamedev speed is the key feature. You can have large data structures, and call it itself(as function parameter for example) can reduce execution speed. Pointer to this data structure can have drastically smaller size than structure itself, and send pointer as the function parameter will be faster in most cases.

1 Like

Hi !

All the people above like said xubpwg, gave you good answers but I think that the best way to understand this concept is with a little illustration but before that it’s really important to understand what is a variable.

Basically, a variable is a temporary block which allows us to store data in memory. To a computer, it’s a memory location identified by an address which contains a data, for us, it’s a name associated with a value.

Knowing that, a pointer is simply a variable which stores the address of another variable.
With the * operator( this kind of operation is called “dereferencing”) you can perform many things:

  • declare a pointer.
  • access or manipulate data contained in memory location pointed to by a pointer.

The concept of pointers is not complex, the idea behind that is really simple, the most difficult part are the responsibilities associated with it.
Pointer is important for many usages, as a beginner, you will understand as you go along.
Understanding this already is essential.

( I made a little picture to show you briefly how it’s working )
Hope it’s will help you.


Nice :smiley: Thanks for explaining. The picture helps me a lot understanding pointers.

I’m glad to hear it :smiley:

I know I’m late to the party here, but I created an forums account just so I could like the replies above. Y’all gave very good explanations, especially with the picture. On a personal note, it took me 1 C/C++ basics class and at least 1 other C/C++ based course (Operating Systems, Computer Architecture, something to the like) to fully understand pointers and their benefits in my undergrad. I was a bit slow to catch onto C/C++ though. O:)

Privacy & Terms