2020-05-29 23:23:24 +03:00
|
|
|
#include <assert.h>
|
2019-07-07 23:20:11 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2020-06-28 18:25:37 +03:00
|
|
|
#include "list.h"
|
2019-07-07 23:20:11 +03:00
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
void print_list(char **array)
|
|
|
|
{
|
2019-07-07 23:20:11 +03:00
|
|
|
int i;
|
2020-06-28 18:25:37 +03:00
|
|
|
for (i = 0; array[i]; i++) printf("%s", array[i]);
|
2019-07-07 23:20:11 +03:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
int main()
|
|
|
|
{
|
2019-07-07 23:20:11 +03:00
|
|
|
List_T list1, list2, list3;
|
2020-05-29 23:23:24 +03:00
|
|
|
char **str1 = (char **)malloc(100 * sizeof(char *));
|
2019-07-07 23:20:11 +03:00
|
|
|
|
|
|
|
list1 = List_init();
|
|
|
|
list1 = List_push(list1, "Dang ");
|
|
|
|
list1 = List_push(list1, "Hoang ");
|
|
|
|
list1 = List_push(list1, "Hai ");
|
|
|
|
printf("List 1: ");
|
|
|
|
str1 = (char **)List_toArray(list1);
|
|
|
|
print_list(str1);
|
|
|
|
|
|
|
|
list2 = List_init();
|
|
|
|
list2 = List_list(list2, "Mentor ", "Graphics ", "Siemens", NULL);
|
|
|
|
printf("List 2: ");
|
|
|
|
print_list((char **)List_toArray(list2));
|
|
|
|
|
|
|
|
list3 = List_append(list1, list2);
|
|
|
|
printf("Test append list2 into list1: ");
|
|
|
|
print_list((char **)List_toArray(list3));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|