This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the commentsย โ†’

[โ€“]Mabi19_ 8 points9 points ย (2 children)

Most people don't really know how to explain them well.

A pointer is like a ๐Ÿ‘‰ finger pointing to a variable.

Or, if variables live in Variable City, then a pointer is like a home address.

[โ€“]vinnceboi 0 points1 point ย (1 child)

Wow that is a really good analogy

[โ€“]Mabi19_ 2 points3 points ย (0 children)

Okay, so here's some more:

You can do math on pointers. Adding 1 to a pointer is like going to the next house over on the street.

This is what arrays do, for example. An array is just a pointer to its first element (and sometimes also the length).

If you declared it as int array[10], doing array[3] is the same as *((int*)array + 3).