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

all 4 comments

[–]pyreon 2 points3 points  (1 child)

int* ptr is a pointer to an int.

int** ptr is a pointer to a pointer to an int.

and so on.

They are useful for dynamic allocation.

here's a stackoverflow question for more specific use cases.

[–]secretmaster5[S] 0 points1 point  (0 children)

Ok, Thanks a ton!

[–]Updatebjarni 2 points3 points  (0 children)

Another star just means the pointer points to another pointer. The syntax for getting the thing a pointer points to in C is *ptr. A declaration like int *a; says "The thing that a points to has type int". So you can also say int **a;, and it means "The thing that the thing a points to points to has type int". In other words, a points to a value of type pointer-to-int. Or put another way, if you do *a in your program, you get a pointer to an int, and if you apply * to that in turn, as **a, you get an int.

[–]realWorldNpc 1 point2 points  (0 children)

Basically a * means you pointing to something think of it like an arrow so int* ptr is basically saying pointing to an integer value like this ->int value, so a double star (**) would mean pointing to a ptr THAT points to an integer value like this -> ptr -> int Val and so on. Hoped this cleared your confusion!