ft_lstaddend
This commit is contained in:
parent
baf67e49a6
commit
5703ae8db7
4
Makefile
4
Makefile
@ -6,7 +6,7 @@
|
||||
# By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# 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 \
|
||||
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_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)
|
||||
INCLS = -I.
|
||||
|
31
ft_lstaddend.c
Normal file
31
ft_lstaddend.c
Normal 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);
|
||||
}
|
@ -6,12 +6,11 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 <stdio.h>
|
||||
|
||||
void ft_lstdel(t_list **alst, void (*del)(void*, size_t))
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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
25
ft_print_words_tables.c
Normal 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++;
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -22,7 +22,7 @@ void ft_sort_params(int ac, char **av)
|
||||
while (++i < ac && (j = 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];
|
||||
j--;
|
||||
|
@ -6,11 +6,10 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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"
|
||||
|
||||
static int count_words(char const *s, char c)
|
||||
|
4
libft.h
4
libft.h
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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_lstgetlast(t_list *lst);
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user