// demonstrates basic pointer use // Michael L. Collard // 11/2/99 int main(){ int n = 1; // create a variable with 5 in int int* p = &n; // creates a pointer that points to n n = 2;// change value of n using n *p = 3;// change value of n through p (dereferencing) int m = 4; // another variable m p = &m; // now points to m *p = 5; // change m // note that * at declaration is not a dereference // opeartor, rather it is a way of telling the compiler // we are declearing a pointer int *p2 = p; // declare pointer and assign it // an address of m *p2 = 6; // change m p=&n;// p now points to n again *p=*p2;// the value of m is assigned to n }