-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
34 lines (32 loc) · 870 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <stdlib.h>
#include "linked_list.h"
const int SIZE_OF_LIST = 20;
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;
}