diff options
53 files changed, 698 insertions, 132 deletions
diff --git a/c01/ex07/ft_rev_int_tab.c b/c01/ex07/ft_rev_int_tab.c index e6b0dea..82922d6 100644 --- a/c01/ex07/ft_rev_int_tab.c +++ b/c01/ex07/ft_rev_int_tab.c @@ -6,7 +6,7 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/03 18:02:02 by cacharle #+# #+# */ -/* Updated: 2019/07/04 06:44:57 by cacharle ### ########.fr */ +/* Updated: 2019/07/22 09:59:51 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,14 +31,14 @@ int main() printf("---------------\n"); int *rult; - int len = ft_ultimate_range(&rult, 0, INT_MAX); + int len = ft_ultimate_range(&rult, 0, 10); printf("len(%d): ", len); for (int i = 0; i < len; i++) printf("%d ", rult[i]); printf("\n "); printf("---------------\n"); - char *strs[] = {"bon", "je", "suis", "charles"}; + char *strs[] = {"bon", "je", "", "charles"}; char *sep = "%&^"; int size = 4; char *join; diff --git a/c12/ex00/ft_create_elem.c b/c12/ex00/ft_create_elem.c index 092833b..472595c 100644 --- a/c12/ex00/ft_create_elem.c +++ b/c12/ex00/ft_create_elem.c @@ -6,18 +6,18 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/09 17:19:22 by cacharle #+# #+# */ -/* Updated: 2019/07/17 18:34:23 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:16:58 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include <stdlib.h> #include "ft_list.h" -t_list *ft_create_elem(void *data) +t_list *ft_create_elem(void *data) { t_list *list; - if((list = (t_list*)malloc(sizeof(t_list))) == NULL) + if ((list = (t_list*)malloc(sizeof(t_list))) == NULL) return (NULL); list->data = data; list->next = NULL; diff --git a/c12/ex00/ft_list.h b/c12/ex00/ft_list.h index 8b736b4..686f459 100644 --- a/c12/ex00/ft_list.h +++ b/c12/ex00/ft_list.h @@ -6,12 +6,12 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/09 14:33:17 by cacharle #+# #+# */ -/* Updated: 2019/07/09 14:42:55 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:18:55 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef FT_LIST_H -#define FT_LIST_H +# define FT_LIST_H typedef struct s_list { @@ -19,6 +19,6 @@ typedef struct s_list void *data; } t_list; -t_list *ft_create_elem(void *data); +t_list *ft_create_elem(void *data); #endif diff --git a/c12/ex01/ft_list.h b/c12/ex01/ft_list.h index 8b736b4..a7a433c 100644 --- a/c12/ex01/ft_list.h +++ b/c12/ex01/ft_list.h @@ -6,12 +6,12 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/09 14:33:17 by cacharle #+# #+# */ -/* Updated: 2019/07/09 14:42:55 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:19:22 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef FT_LIST_H -#define FT_LIST_H +# define FT_LIST_H typedef struct s_list { @@ -19,6 +19,6 @@ typedef struct s_list void *data; } t_list; -t_list *ft_create_elem(void *data); +t_list *ft_create_elem(void *data); #endif diff --git a/c12/ex01/ft_list_push_front.c b/c12/ex01/ft_list_push_front.c index 76fedd9..867b007 100644 --- a/c12/ex01/ft_list_push_front.c +++ b/c12/ex01/ft_list_push_front.c @@ -6,11 +6,11 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/09 17:19:14 by cacharle #+# #+# */ -/* Updated: 2019/07/17 17:10:46 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:16:43 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ - +#include <stdlib.h> #include "ft_list.h" void ft_list_push_front(t_list **begin_list, void *data) diff --git a/c12/ex02/ft_list.h b/c12/ex02/ft_list.h index 33ad610..c98b98d 100644 --- a/c12/ex02/ft_list.h +++ b/c12/ex02/ft_list.h @@ -6,12 +6,12 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/09 14:33:17 by cacharle #+# #+# */ -/* Updated: 2019/07/19 08:29:04 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:17:13 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef FT_LIST_H -#define FT_LIST_H +# define FT_LIST_H typedef struct s_list { diff --git a/c12/ex03/ft_list.h b/c12/ex03/ft_list.h index 32a5925..0167a74 100644 --- a/c12/ex03/ft_list.h +++ b/c12/ex03/ft_list.h @@ -6,12 +6,12 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/09 14:33:17 by cacharle #+# #+# */ -/* Updated: 2019/07/19 08:28:53 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:17:26 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef FT_LIST_H -#define FT_LIST_H +# define FT_LIST_H typedef struct s_list { diff --git a/c12/ex03/ft_list_last.c b/c12/ex03/ft_list_last.c index 84a46c2..2164e34 100644 --- a/c12/ex03/ft_list_last.c +++ b/c12/ex03/ft_list_last.c @@ -6,14 +6,17 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/09 17:18:58 by cacharle #+# #+# */ -/* Updated: 2019/07/17 17:30:36 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:37:03 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ +#include <stdlib.h> #include "ft_list.h" t_list *ft_list_last(t_list *begin_list) { + if (begin_list == NULL) + return (NULL); while (begin_list->next != NULL) begin_list = begin_list->next; return (begin_list); diff --git a/c12/ex04/ft_list.h b/c12/ex04/ft_list.h index 8b736b4..3ea2dcb 100644 --- a/c12/ex04/ft_list.h +++ b/c12/ex04/ft_list.h @@ -6,12 +6,12 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/09 14:33:17 by cacharle #+# #+# */ -/* Updated: 2019/07/09 14:42:55 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:19:58 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef FT_LIST_H -#define FT_LIST_H +# define FT_LIST_H typedef struct s_list { @@ -19,6 +19,6 @@ typedef struct s_list void *data; } t_list; -t_list *ft_create_elem(void *data); +t_list *ft_create_elem(void *data); #endif diff --git a/c12/ex04/ft_list_push_back.c b/c12/ex04/ft_list_push_back.c index db4fdb0..b4c486b 100644 --- a/c12/ex04/ft_list_push_back.c +++ b/c12/ex04/ft_list_push_back.c @@ -6,23 +6,26 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/09 17:18:46 by cacharle #+# #+# */ -/* Updated: 2019/07/17 18:04:28 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:42:15 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ +#include <stdlib.h> #include "ft_list.h" -void ft_list_push_back(t_list **begin_list, void *data) +void ft_list_push_back(t_list **begin_list, void *data) { t_list *new_rear; + t_list *cursor; new_rear = ft_create_elem(data); - if (!*begin_list) + if (*begin_list == NULL) { - (*begin_list) = new_rear; + *begin_list = new_rear; return ; } - while ((*begin_list)->next) - *begin_list = (*begin_list)->next; - (*begin_list)->next = new_rear; + cursor = *begin_list; + while (cursor->next) + cursor = cursor->next; + cursor->next = new_rear; } diff --git a/c12/ex05/ft_list.h b/c12/ex05/ft_list.h index 8b736b4..b5a05a2 100644 --- a/c12/ex05/ft_list.h +++ b/c12/ex05/ft_list.h @@ -6,12 +6,12 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/09 14:33:17 by cacharle #+# #+# */ -/* Updated: 2019/07/09 14:42:55 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:19:36 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef FT_LIST_H -#define FT_LIST_H +# define FT_LIST_H typedef struct s_list { @@ -19,6 +19,6 @@ typedef struct s_list void *data; } t_list; -t_list *ft_create_elem(void *data); +t_list *ft_create_elem(void *data); #endif diff --git a/c12/ex05/ft_list_push_strs.c b/c12/ex05/ft_list_push_strs.c index e56cd18..43c24a7 100644 --- a/c12/ex05/ft_list_push_strs.c +++ b/c12/ex05/ft_list_push_strs.c @@ -6,13 +6,14 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/09 17:18:23 by cacharle #+# #+# */ -/* Updated: 2019/07/17 18:34:23 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:42:33 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ +#include <stdlib.h> #include "ft_list.h" -void list_push_front(t_list **begin_list, void *data) +static void push_front(t_list **begin_list, void *data) { t_list *new_front; @@ -21,14 +22,14 @@ void list_push_front(t_list **begin_list, void *data) *begin_list = new_front; } -t_list *ft_list_push_strs(int size, char **strs) +t_list *ft_list_push_strs(int size, char **strs) { - int i; + int i; t_list *list; list = NULL; i = 0; while (i < size) - list_push_front(&list, strs[i++]); + push_front(&list, strs[i++]); return (list); } diff --git a/c12/ex06/ft_list.h b/c12/ex06/ft_list.h index aeb710e..d64c942 100644 --- a/c12/ex06/ft_list.h +++ b/c12/ex06/ft_list.h @@ -6,12 +6,12 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/09 14:33:17 by cacharle #+# #+# */ -/* Updated: 2019/07/19 08:28:35 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:18:03 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef FT_LIST_H -#define FT_LIST_H +# define FT_LIST_H typedef struct s_list { diff --git a/c12/ex06/ft_list_clear.c b/c12/ex06/ft_list_clear.c index 811469b..2263bf0 100644 --- a/c12/ex06/ft_list_clear.c +++ b/c12/ex06/ft_list_clear.c @@ -6,18 +6,17 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/09 17:53:02 by cacharle #+# #+# */ -/* Updated: 2019/07/17 18:20:11 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:42:46 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ +#include <stdlib.h> #include "ft_list.h" -void ft_list_clear(t_list *begin_list, void (*free_fct)(void *)) +void ft_list_clear(t_list *begin_list, void (*free_fct)(void *)) { t_list *tmp; - if (begin_list == NULL) - return ; while (begin_list) { free_fct(begin_list->data); diff --git a/c12/ex07/ft_list.h b/c12/ex07/ft_list.h index ab7e2d1..3888011 100644 --- a/c12/ex07/ft_list.h +++ b/c12/ex07/ft_list.h @@ -6,12 +6,12 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/09 14:33:17 by cacharle #+# #+# */ -/* Updated: 2019/07/19 08:28:24 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:18:13 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef FT_LIST_H -#define FT_LIST_H +# define FT_LIST_H typedef struct s_list { diff --git a/c12/ex07/ft_list_at.c b/c12/ex07/ft_list_at.c index ad4b084..3e4d7ca 100644 --- a/c12/ex07/ft_list_at.c +++ b/c12/ex07/ft_list_at.c @@ -6,15 +6,16 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/09 17:56:31 by cacharle #+# #+# */ -/* Updated: 2019/07/17 18:36:07 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:42:59 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ +#include <stdlib.h> #include "ft_list.h" -t_list *ft_list_at(t_list *begin_list, unsigned int nbr) +t_list *ft_list_at(t_list *begin_list, unsigned int nbr) { - while (nbr-- > 0 && begin_list) + while (nbr-- > 0 && begin_list != NULL) begin_list = begin_list->next; return (begin_list); } diff --git a/c12/ex08/ft_list.h b/c12/ex08/ft_list.h index 0744591..d4fdda0 100644 --- a/c12/ex08/ft_list.h +++ b/c12/ex08/ft_list.h @@ -6,12 +6,12 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/09 14:33:17 by cacharle #+# #+# */ -/* Updated: 2019/07/19 08:28:13 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:18:20 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef FT_LIST_H -#define FT_LIST_H +# define FT_LIST_H typedef struct s_list { diff --git a/c12/ex08/ft_list_reverse.c b/c12/ex08/ft_list_reverse.c index e5c2057..a849c3a 100644 --- a/c12/ex08/ft_list_reverse.c +++ b/c12/ex08/ft_list_reverse.c @@ -6,11 +6,14 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/09 18:05:23 by cacharle #+# #+# */ -/* Updated: 2019/07/19 08:18:13 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:42:03 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ -void ft_list_reverse(t_list **begin_list) +#include <stdlib.h> +#include "ft_list.h" + +void ft_list_reverse(t_list **begin_list) { t_list *cursor; t_list *prev; diff --git a/c12/ex09/ft_list.h b/c12/ex09/ft_list.h index 8f3a487..c46b6e5 100644 --- a/c12/ex09/ft_list.h +++ b/c12/ex09/ft_list.h @@ -6,7 +6,7 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/09 14:33:17 by cacharle #+# #+# */ -/* Updated: 2019/07/19 08:27:40 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:18:29 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/c12/ex09/ft_list_foreach.c b/c12/ex09/ft_list_foreach.c index 2c9705f..15fe1ef 100644 --- a/c12/ex09/ft_list_foreach.c +++ b/c12/ex09/ft_list_foreach.c @@ -6,11 +6,14 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/19 08:29:57 by cacharle #+# #+# */ -/* Updated: 2019/07/19 08:31:03 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:43:14 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ -void ft_list_foreach(t_list *begin_list, void (*f)(void *)) +#include <stdlib.h> +#include "ft_list.h" + +void ft_list_foreach(t_list *begin_list, void (*f)(void *)) { while (begin_list != NULL) { diff --git a/c12/ex10/ft_list.h b/c12/ex10/ft_list.h index 5a8dab5..7cecff1 100644 --- a/c12/ex10/ft_list.h +++ b/c12/ex10/ft_list.h @@ -6,12 +6,12 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/09 14:33:17 by cacharle #+# #+# */ -/* Updated: 2019/07/19 08:27:25 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:20:47 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef FT_LIST_H -#define FT_LIST_H +# define FT_LIST_H typedef struct s_list { diff --git a/c12/ex10/ft_list_foreach_if.c b/c12/ex10/ft_list_foreach_if.c index 944e31b..4fd6d73 100644 --- a/c12/ex10/ft_list_foreach_if.c +++ b/c12/ex10/ft_list_foreach_if.c @@ -6,14 +6,20 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/19 08:31:11 by cacharle #+# #+# */ -/* Updated: 2019/07/19 08:34:48 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:44:03 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ -void ft_list_foreach_if(t_list *begin_list, void (*f)(void *), void - *data_ref, int (*cmp)()) +#include <stdlib.h> +#include "ft_list.h" + +void ft_list_foreach_if(t_list *begin_list, void (*f)(void *), + void *data_ref, int (*cmp)()) { while (begin_list != NULL) + { if ((*cmp)(begin_list->data, data_ref) == 0) (*f)(begin_list->data); + begin_list = begin_list->next; + } } diff --git a/c12/ex11/ft_list.h b/c12/ex11/ft_list.h index 698a86c..ca62a2f 100644 --- a/c12/ex11/ft_list.h +++ b/c12/ex11/ft_list.h @@ -6,12 +6,12 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/09 14:33:17 by cacharle #+# #+# */ -/* Updated: 2019/07/19 08:27:07 by cacharle ### ########.fr */ +/* Updated: 2019/07/23 15:21:14 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef FT_LIST_H -#define FT_LIST_H +# define FT_LIST_H typedef struct s_list { diff --git a/c12/ex11/ft_list_find.c b/c12/ex11/ft_list_find.c index e0d22e8..00d7903 100644 --- a/c12/ex11/ft_list_find.c +++ b/c12/ex11/ft_list_find.c @@ -6,11 +6,14 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ |
