Pointing the Way
So now that we know what pointers are, how do we create and use them?
Remember, a pointer is a variable just like any other.
So, in C, we must declare our pointer variables.
A pointer to a character would be declared like:
which means to define a variable called
which will normally
hold the address of some character.
The syntax is meant to indicate the the expression
In fact, that identifies the first aspect of using pointers.
a pointer, which means that
the value of the expression
is the character to which
For example, the code fragment
*p = 'b';
would set the character to which
points to be the character
and would then print it out.
This illustrates that a dereferenced pointer may be used anywhere any
other variable or expression of that type may be used.