int main() { Linked_List *linked_list = NULL; int error_code; int i; for(i = 0; i < SIZE_OF_LIST; ++i) { error_code = add_linked_list(&linked_list, i); if(error_code) { fprintf(stderr, "\nError. Adding item (%d) failed.\n", i); return EXIT_FAILURE; } } print_linked_list(linked_list); printf("\nReversing list..."); error_code = reverse_linked_list(&linked_list); if(error_code) { fprintf(stderr, "\nError. Reversing list failed.\n"); } print_linked_list(linked_list); printf("\nRemoving 3rd node from end of list..."); error_code = remove_nth_from_end(&linked_list, 3); if(error_code) { fprintf(stderr, "\nError. Removing nth node list failed.\n"); } print_linked_list(linked_list); destroy_linked_list(linked_list); return EXIT_SUCCESS; }
int main() { // Initialise a root node and define a traversal node struct node *root; // Make the 'rand' function generate random numbers srand(time(NULL)); // Generate a random linked list root = generate_list(5, 10); // Print the list print_list(root); // Reverse the list root = reverse_linked_list(root); // Print the list again print_list(root); return(0); }