So now we learned what a pointer is and how to create one, but is there a way to obtain the value pointed to by the pointer?
The asterisk sign
* a.k.a. the dereference operator is used to obtain the value pointed to by a variable. This can be done by preceding the name of a pointer variable with
int blah = *ptr;
The double meaning of the
* symbol can be tricky at first, so make sure to note:
*is used in a declaration, it is creating a pointer.
*is not used in a declaration, it is a dereference operator.
What do you think it will output?