Prelude to C: Pointers09-02-21
If you’re new to pointers it can seem like an unknowable, abstract concept.
I felt like Chris Farley in Almost Heroes when I made first contact with the idea of pointers.
Pointers are simple if you understand the high-level way in which memory works.
let x = 33
When we write that assignment we’re saying:
“Hey, browser! Let the operating system know I want to store the number 33 in memory. I don’t care where in memory it stores it, just give give me the address so I can get to it later.”
A pointer is the address the operating system gave us for
Now, when we want to do something like
x * 1 we’re saying:
“Hey browser! Let the operating system know I want to get the value stored at
the address it gave me for
x so I can multiply
x by 1.”
It’s that simple.
Congratulations, you understand pointers.
Now, there are some more complicated things you can do with pointers in C, but that’s a post for later.
Today, I just wanted to expose you to the basic concept.