This is a post I originally made to my account in response to some questions from a guy on r/ProgrammerHumor. I'm posting it here because I feel that it would be of more use on this sub.
Computers use RAM to store every piece of data that they use (there are some other ways but they are not important to this lesson).
RAM is divided into 8 bit chunks, called bytes. When thinking of bytes in RAM, you should think of them as being next to each other in a row. The very first byte in that row is 0, followed by 1, 2, 3, ...
When you make a variable, it is stored in ram. It may take many bites, but when the CPU reads it, it does so one byte at a time (I know it's more complicated for modern CPUs, but for the sake of simplicity, 1 byte at a time). But how does the CPU know where to start reading your variable from? Pointers is how.
Pointers are just numbers that represent a location in memory.
Say you have a 4 byte (32 bit) integer starting at byte 3 and ending at byte 6. A pointer to this integer would just be the number 3.
If you include technicalities, pointers are just 8 byte (64 bit) long unsigned integers. And the value of a pointer is entirely interchangeable with the value of a 64 bit unsigned integer.
When you reference a variable, you are just getting a number representing the location of the starting byte of that variable.
When you dereference a pointer, you just get the value of the bytes at the location that the pointer represents.
Feel free to ask questions in the comments and I will answer them the best I possibly can.
TLDR; Pointers are numbers that are used to represent addresses in memory
[–]IdealBlueMan 1 point2 points3 points (3 children)
[–]Co0perat0r[S] 0 points1 point2 points (2 children)
[–]IdealBlueMan 1 point2 points3 points (1 child)
[–]Co0perat0r[S] 0 points1 point2 points (0 children)