// FILE: test5.cxx #include struct node { int data; node * next; }; void printlist(node * point) { node * temp; temp = point; do { cout << temp->data << " " ; temp = temp->next;} while (!(temp == NULL)); cout << "end of list" << endl; } main () { node *p, *q, *r; int temp; //create space for node and let p point to that space p = new node; //now store appropriate values in both sections p->next = NULL; p->data = 1 ; printlist(p); //copy the data section of the node p points to temp = p->data; cout << temp << endl; //create space for new and let q point to that space q = new node; //link the node p points to to this new node p->next = q; //now store appropriate values in both sections q->data = 2; q->next = NULL; printlist(p); //try again r = new node; q->next = r; r->next = NULL; r->data = 3; printlist(p); cout << "that's all folks!" << endl; }