libasm/main.c

101 lines
2.0 KiB
C

#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include "libasm.h"
int ft_strcmp(const char *s1, const char *s2) {
printf("s1: %ss2: %s", s1, s2);
while (*s1 && *s2 && *s1 == *s2) {
s1++;
s2++;
}
return *s1 - *s2;
}
int main(void) {
t_list *list;
list = NULL;
ft_list_push_front(&list, "toto\n");
ft_list_push_front(&list, "tutu\n");
ft_list_push_front(&list, "zaza\n");
ft_list_push_front(&list, "bobo\n");
ft_list_push_front(&list, "tata\n");
ft_list_push_front(&list, "babar\n");
ft_list_push_front(&list, "zoro\n");
ft_list_print(list);
printf("%lu\n", sizeof(t_list));
printf("%d\n", ft_list_size(list));
ft_list_sort(&list, &ft_strcmp);
ft_list_print(list);
t_list *a;
a = NULL;
ft_list_push_front(&a, "d\n");
ft_list_push_front(&a, "c\n");
ft_list_push_front(&a, "b\n");
ft_list_push_front(&a, "a\n");
ft_list_print(a);
ft_list_sort(&a, &ft_strcmp);
printf("On est sorti.e.s de cet enfer\n");
ft_list_print(a);
t_list *b;
b = NULL;
ft_list_push_front(&b, "ziziron\n");
ft_list_push_front(&b, "abalon\n");
ft_list_push_front(&b, "zebulon\n");
ft_list_print(b);
ft_list_sort(&b, &ft_strcmp);
ft_list_print(b);
t_list *null = NULL;
ft_list_sort(&null, &ft_strcmp);
t_list *begin_ok = NULL;
ft_list_push_front(&begin_ok, "c");
ft_list_push_front(&begin_ok, "f");
ft_list_push_front(&begin_ok, "b");
ft_list_push_front(&begin_ok, "h");
ft_list_push_front(&begin_ok, "e");
ft_list_push_front(&begin_ok, "l");
ft_list_push_front(&begin_ok, "d");
ft_list_push_front(&begin_ok, "i");
ft_list_push_front(&begin_ok, "j");
ft_list_push_front(&begin_ok, "k");
ft_list_push_front(&begin_ok, "g");
ft_list_push_front(&begin_ok, "a");
ft_list_print(begin_ok);
printf("\n");
ft_list_sort(&begin_ok, &ft_strcmp);
printf("\n");
printf("\n");
ft_list_print(begin_ok);
printf("\n");
t_list *c = NULL;
ft_list_push_front(&c, "b\n");
ft_list_push_front(&c, "c\n");
ft_list_push_front(&c, "a\n");
ft_list_print(c);
ft_list_sort(&c, *ft_strcmp);
ft_list_print(c);
return 0;
}