// file: ll_00.cc // // system include files // #include "ll.h" // method: insert // // insert link at the first location // void insert(struct node** head_a, char* data_a) { //create a link struct node *link = (struct node*) malloc(sizeof(struct node)); //link->key = key; // link->data = data; // link->data = new char[strlen(data_a) + 1]; strcpy(link->data, data_a); //point it to old first node link->next = *head_a; //point first to new first node *head_a = link; } // method: printList // // display the list // void printList(struct node* head) { struct node *ptr = head; printf("[head] =>"); //start from the beginning while(ptr != NULL) { printf(" %s =>",ptr->data); ptr = ptr->next; } printf(" [null]\n"); }