Hacker News new | ask | show | jobs
by andrew-nguyen 2199 days ago
I'd rethink the this part of the explanation:

And this is how many times we're allowed to use the dereference operator: one time

I can see what you meant, but I initially thought this was trying to say that a pointer declared with a single asterisk could only be dereferenced once and never dereferenced again afterwards (as if there was a "one-time-use only" property to pointers). In the same vein, the "super_pointer" example could be misinterpreted like "Oh, so if I want a pointer that will let me dereference it on 5 different occasions, then I'll need to declare it with 5 asterisks?" I think a better way would be to replace the "how many times we're allowed to use the dereference operator" explanation and start with explaining the idea of a double pointer

  int **doublePtr
in depth first. With a solid understanding of a double pointer (an address that points to a memory location that contains an address that points to another memory location), making the mental jump to understand

  int *****super_pointer
should be easier.

Also, I think low addresses aren't used for various reasons, but I believe the kernel is stored in the top, high-address region of the address space. Otherwise, I think this is a really solid explanation of pointers!

1 comments

> I can see what you meant, but I initially thought this was trying to say that a pointer declared with a single asterisk could only be dereferenced once and never dereferenced again afterwards

Ah, haha, I see! You're right. This could've been me back in the day.

> Also, I think low addresses aren't used for various reasons, but I believe the kernel is stored in the top, high-address region of the address space.

Ah, yea, I was foggy on this.

For what reasons aren't they used then?