#include #include //Fixed! struct node { char value; struct node *next; }; typedef struct node Node; int main() { Node *start, *end, *tmp, *tmp2; char input; start = end = tmp = tmp2 = (Node *) malloc (sizeof(Node)*1); tmp -> value = 0; tmp -> next = NULL; fprintf(stdout, "Enter a value (-1 to complete): "); fscanf(stdin, "%hhd", &input); while (input != -1) { end -> value = input; end -> next = (Node *) malloc (sizeof(Node)*1); end -> next -> value = 0; end -> next -> next = NULL; fprintf(stdout, "Enter a value (-1 to complete): "); fscanf(stdin, "%hhd", &input); if (input == -1) { free(end -> next); end -> next = NULL; } else end = end -> next; } // Display list from start to end fprintf(stdout, "Enter value for new node: "); fscanf(stdin, "%hhd", &input); tmp = (Node *) malloc (sizeof(Node)); tmp -> value = input; tmp -> next = NULL; fprintf(stdout, "Enter value of node you want to insert new node before: "); fscanf(stdin, "%hhd", &input); tmp2 = start; while (tmp2 -> next -> value != input) // replaced 'tmp -> value' with 'input' tmp2 = tmp2 -> next; tmp -> next = tmp2 -> next; tmp2 -> next = tmp; // Display list from start to end return(0); }