Search Results
6/26/2025, 5:24:32 PM
Your computer has little boxes inside it.
All the boxes have funny names like 0xea37168f43ec58bf. But that's a hard to remember computer name. That's called the address. It's like a mail address for the little boxes in your computer!
When you make a program, you write easy to remember names on the boxes. That's called declaring a variable. When you label the box like that, you can put things in the box and get them out easily because you remember you put them in the box labeled whatever.
You can put all sorts of things in the boxes, like numbers and letters. You can even put in the address of other boxes. A box that contains the address of another box is called a pointer.
You might not remember the address of the boxes you wrote labels on (variables), but you can ask the computer to tell you it. If you've got a box called a, you can ask for the address with &a. Then you can put that address inside one of your pointer boxes.
Maybe you've got an address written in one of your pointer boxes, but you want to find out what's in the box written on the label. If you have a pointer box called p, you can ask the computer to get you what's inside the box that's being pointed to with *p. That's called dereferencing a pointer.
Pointers can point to any kind of box, even other pointer boxes. You can even put in a fake address of a box that doesn't exist, or no address at all (null pointer). But you better be careful if you try to dereference one of those, because the computer will get angry and crash.
Most boxes only contain one value, but with pointers, you can do some fun things like point to the start of an array of boxes. That means you could store lots of data in boxes that are right next to each other so they're easy to access together. You only need to remember the address of the first box, which is what a pointer can help you with.
You could even point to an array of pointers, each pointing to their own array of boxes.
All the boxes have funny names like 0xea37168f43ec58bf. But that's a hard to remember computer name. That's called the address. It's like a mail address for the little boxes in your computer!
When you make a program, you write easy to remember names on the boxes. That's called declaring a variable. When you label the box like that, you can put things in the box and get them out easily because you remember you put them in the box labeled whatever.
You can put all sorts of things in the boxes, like numbers and letters. You can even put in the address of other boxes. A box that contains the address of another box is called a pointer.
You might not remember the address of the boxes you wrote labels on (variables), but you can ask the computer to tell you it. If you've got a box called a, you can ask for the address with &a. Then you can put that address inside one of your pointer boxes.
Maybe you've got an address written in one of your pointer boxes, but you want to find out what's in the box written on the label. If you have a pointer box called p, you can ask the computer to get you what's inside the box that's being pointed to with *p. That's called dereferencing a pointer.
Pointers can point to any kind of box, even other pointer boxes. You can even put in a fake address of a box that doesn't exist, or no address at all (null pointer). But you better be careful if you try to dereference one of those, because the computer will get angry and crash.
Most boxes only contain one value, but with pointers, you can do some fun things like point to the start of an array of boxes. That means you could store lots of data in boxes that are right next to each other so they're easy to access together. You only need to remember the address of the first box, which is what a pointer can help you with.
You could even point to an array of pointers, each pointing to their own array of boxes.
Page 1