Initializing Pointers
Initializing Pointers

When pointers are declared, enough memory to hold the address of the dataType the pointer will point to is allocated, but NOT initialized. So until you initialize the pointer it could be 0 or NULL or anything in memory depending on what the memory was being used for before.

Here are a few examples of ways to initialze pointers:

aPtr = &a; /* Assign the pointer, aPtr, the address of the * variable a. */ iPtr = NULL; /* Initialze the pointer, iPtr, to NULL. */ tempPtr = aPtr; /* Make tempPtr point to the same address aPtr * is pointing to. */


Main Page
Last Modified 10 November 2000