/* --------------------------------------------------------------------- ** Figure 12.5: Pointer operations. ** --------------------------------------------------------------------- */ #include void main( void ) { int * pt = NULL; /* An int pointer variable, initialized to NULL. */ int * p; /* A pointer variable that can point at any int. */ int k = 17; /* An integer variable initialized to 17. */ int m; p = &k; /* Use & to set a pointer to k's memory location. */ pt = p; /* Copy a pointer. */ m = *p + 2; /* Add 2 to the value of p's referent; store result in m. */ *p = m; /* Copy the value of m into p's referent. */ printf( "address of p: %i contents of p: %i\n", (int)&p, (int)p ); printf( "address of pt: %i contents of pt: %i\n", (int)&pt, (int)pt ); printf( "address of k: %i contents of k: %i\n", (int)&k, k ); printf( "address of m: %i contents of m: %i\n", (int)&m, m ); }