previous | start | next

2. What is a pointer?

A pointer value is just a memory address of some other value. Suppose this other value has type int. Then the type of the pointer is pointer to int.

Here is how to declare a variable p of type pointer to int.

      int *p;  // preferred form

or

      int* p;  

or

      int * p; 
   

But how can we get values to assign to p?

One very special value is NULL. This is just the address 0.

It is special because this location is protected and provides no access (read or write) to the contents of address 0. Consequently, it is useful to think of this address as meaning the pointer with value NULL is initiallized but is not pointing to any value - don't try to get the value!!



previous | start | next