ft_lstaddend

This commit is contained in:
Tanguy MAZE 2018-04-19 14:41:21 +02:00
parent baf67e49a6
commit 5703ae8db7
9 changed files with 66 additions and 10 deletions

View File

@ -6,7 +6,7 @@
# By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ # # By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2018/04/07 12:47:06 by tmaze #+# #+# # # Created: 2018/04/07 12:47:06 by tmaze #+# #+# #
# Updated: 2018/04/09 18:27:22 by tmaze ### ########.fr # # Updated: 2018/04/19 12:24:45 by tmaze ### ########.fr #
# # # #
#******************************************************************************# #******************************************************************************#
@ -19,7 +19,7 @@ NAME = libft.a
SRCS = ft_memset.c ft_bzero.c ft_memcpy.c ft_memccpy.c ft_memmove.c ft_memchr.c ft_memcmp.c ft_strlen.c ft_strdup.c ft_strcpy.c ft_strncpy.c ft_strcat.c ft_strncat.c ft_strlcat.c ft_strchr.c ft_strrchr.c ft_strstr.c ft_strnstr.c ft_strcmp.c ft_strncmp.c ft_atoi.c ft_isalpha.c ft_isdigit.c ft_isalnum.c ft_isascii.c ft_isprint.c ft_toupper.c ft_tolower.c \ SRCS = ft_memset.c ft_bzero.c ft_memcpy.c ft_memccpy.c ft_memmove.c ft_memchr.c ft_memcmp.c ft_strlen.c ft_strdup.c ft_strcpy.c ft_strncpy.c ft_strcat.c ft_strncat.c ft_strlcat.c ft_strchr.c ft_strrchr.c ft_strstr.c ft_strnstr.c ft_strcmp.c ft_strncmp.c ft_atoi.c ft_isalpha.c ft_isdigit.c ft_isalnum.c ft_isascii.c ft_isprint.c ft_toupper.c ft_tolower.c \
ft_memalloc.c ft_memdel.c ft_strnew.c ft_strdel.c ft_strclr.c ft_striter.c ft_striteri.c ft_strmap.c ft_strmapi.c ft_strequ.c ft_strnequ.c ft_strsub.c ft_strjoin.c ft_strtrim.c ft_strsplit.c ft_itoa.c ft_putchar.c ft_putstr.c ft_putendl.c ft_putnbr.c ft_putchar_fd.c ft_putstr_fd.c ft_putendl_fd.c ft_putnbr_fd.c\ ft_memalloc.c ft_memdel.c ft_strnew.c ft_strdel.c ft_strclr.c ft_striter.c ft_striteri.c ft_strmap.c ft_strmapi.c ft_strequ.c ft_strnequ.c ft_strsub.c ft_strjoin.c ft_strtrim.c ft_strsplit.c ft_itoa.c ft_putchar.c ft_putstr.c ft_putendl.c ft_putnbr.c ft_putchar_fd.c ft_putstr_fd.c ft_putendl_fd.c ft_putnbr_fd.c\
ft_lstnew.c ft_lstdelone.c ft_lstdel.c ft_lstadd.c ft_lstiter.c ft_lstmap.c \ ft_lstnew.c ft_lstdelone.c ft_lstdel.c ft_lstadd.c ft_lstiter.c ft_lstmap.c \
ft_isupper.c ft_islower.c ft_str_is_alpha.c ft_str_is_lowercase.c ft_str_is_numeric.c ft_str_is_printable.c ft_str_is_uppercase.c ft_strcapitalize.c ft_strlcpy.c ft_strlowcase.c ft_strupcase.c ft_lstsize.c ft_lstgetat.c ft_lstgetlast.c ft_sort_params.c ft_isupper.c ft_islower.c ft_str_is_alpha.c ft_str_is_lowercase.c ft_str_is_numeric.c ft_str_is_printable.c ft_str_is_uppercase.c ft_strcapitalize.c ft_strlcpy.c ft_strlowcase.c ft_strupcase.c ft_lstsize.c ft_lstgetat.c ft_lstgetlast.c ft_sort_params.c ft_print_words_tables.c ft_lstaddend.c
OBJS = $(SRCS:.c=.o) OBJS = $(SRCS:.c=.o)
INCLS = -I. INCLS = -I.

31
ft_lstaddend.c Normal file
View File

@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstaddend.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/17 20:55:26 by tmaze #+# #+# */
/* Updated: 2018/04/19 14:32:44 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstaddend(t_list **alst, t_list *new)
{
t_list **tmp;
if (new == NULL)
return (NULL);
if (ft_lstsize(*alst) == 0)
ft_lstadd(alst, new);
else if (ft_lstsize(*alst) > 0)
{
if ((tmp = (t_list**)malloc(sizeof(t_list*))) == NULL)
return (NULL);
*tmp = ft_lstgetlast(*alst);
ft_lstadd(&(*tmp)->next, new);
}
return (*alst);
}

View File

@ -6,12 +6,11 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */ /* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/08 17:19:32 by tmaze #+# #+# */ /* Created: 2018/04/08 17:19:32 by tmaze #+# #+# */
/* Updated: 2018/04/08 19:20:07 by tmaze ### ########.fr */ /* Updated: 2018/04/19 14:36:46 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "libft.h" #include "libft.h"
#include <stdio.h>
void ft_lstdel(t_list **alst, void (*del)(void*, size_t)) void ft_lstdel(t_list **alst, void (*del)(void*, size_t))
{ {

View File

@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */ /* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/09 17:34:10 by tmaze #+# #+# */ /* Created: 2018/04/09 17:34:10 by tmaze #+# #+# */
/* Updated: 2018/04/09 17:39:37 by tmaze ### ########.fr */ /* Updated: 2018/04/12 12:23:02 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

25
ft_print_words_tables.c Normal file
View File

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_words_tables.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/15 15:48:16 by tmaze #+# #+# */
/* Updated: 2018/04/15 15:51:21 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_print_words_tables(char **tab)
{
unsigned int i;
i = 0;
while(tab[i])
{
ft_putendl(tab[i]);
i++;
}
}

View File

@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */ /* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/07 19:13:17 by tmaze #+# #+# */ /* Created: 2018/04/07 19:13:17 by tmaze #+# #+# */
/* Updated: 2018/04/10 14:20:31 by tmaze ### ########.fr */ /* Updated: 2018/04/12 11:23:29 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -22,7 +22,7 @@ void ft_sort_params(int ac, char **av)
while (++i < ac && (j = i)) while (++i < ac && (j = i))
{ {
tmp = av[i]; tmp = av[i];
while (j > 1 && strcmp(av[j - 1], tmp) > 0) while (j > 1 && ft_strcmp(av[j - 1], tmp) > 0)
{ {
av[j] = av[j - 1]; av[j] = av[j - 1];
j--; j--;

View File

@ -6,11 +6,10 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */ /* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/07 17:54:29 by tmaze #+# #+# */ /* Created: 2018/04/07 17:54:29 by tmaze #+# #+# */
/* Updated: 2018/04/10 14:12:54 by tmaze ### ########.fr */ /* Updated: 2018/04/15 15:55:03 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include <stdio.h>
#include "libft.h" #include "libft.h"
static int count_words(char const *s, char c) static int count_words(char const *s, char c)

View File

@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */ /* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/08 00:12:36 by tmaze #+# #+# */ /* Created: 2018/04/08 00:12:36 by tmaze #+# #+# */
/* Updated: 2018/04/10 19:08:03 by tmaze ### ########.fr */ /* Updated: 2018/04/19 14:25:55 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -125,5 +125,7 @@ size_t ft_lstsize(t_list *lst);
t_list *ft_lstgetat(t_list *lst, size_t ind); t_list *ft_lstgetat(t_list *lst, size_t ind);
t_list *ft_lstgetlast(t_list *lst); t_list *ft_lstgetlast(t_list *lst);
void ft_sort_params(int ac, char **av); void ft_sort_params(int ac, char **av);
void ft_print_words_tables(char **tab);
t_list *ft_lstaddend(t_list **alst, t_list *new);
#endif #endif