#include #include "linkedlist.h" int main() { Node *start, *tmp, *tmp2; char input, i; start = tmp = tmp2 = NULL; printf("Phase 1: Building a list\n"); printf("------------------------\n"); printf("Enter a value (0-127) [-1 to quit]: "); scanf("%hhd", &input); while (input != -1) { tmp2 = (Node *) malloc (sizeof(Node)); tmp2 -> value = input; tmp2 -> next = NULL; start = appendnode(start, tmp, tmp2); if (tmp == NULL) tmp = start; if (tmp -> next != NULL) tmp = tmp -> next; printf("Enter a value (0-127) [-1 to quit]: "); scanf("%hhd", &input); } printf("\n\nPhase 2: Displaying the list\n"); printf("-----------------------------\n"); i = showlist(start); printf("\n\nPhase 3: Selecting a Node to Append After\n"); printf("---------------------------------------------\n"); do { printf("Select a node # to append after (0-%hhd): ", i); scanf("%hhd", &input); tmp = getpos(start, input); } while (tmp == NULL); printf("\n\nPhase 4: Append New Node After Specified Node\n"); printf("-------------------------------------------------\n"); printf("Enter a value (0-127) for new node: "); scanf("%hhd", &input); tmp2 = (Node *) malloc (sizeof(Node)); tmp2 -> value = input; tmp2 -> next = NULL; start = appendnode(start, tmp, tmp2); printf("\n\nPhase 5: Displaying the list\n"); printf("-----------------------------\n"); showlist(start); return(0); }