ft_lst2str

This commit is contained in:
ariard 2017-08-16 19:52:29 +02:00
parent 91f79ea663
commit 98168e630e
5 changed files with 28 additions and 1 deletions

View file

@ -108,6 +108,7 @@ lst/ft_lst_pop.c\
lst/pop.c\ lst/pop.c\
lst/push.c\ lst/push.c\
lst/top.c\ lst/top.c\
lst/ft_lst2str.c\
math/ft_addrcmp.c\ math/ft_addrcmp.c\
math/ft_ilen.c\ math/ft_ilen.c\
math/ft_ilen_base.c\ math/ft_ilen_base.c\

0
libft/STDBUG Normal file
View file

View file

@ -89,5 +89,6 @@ void lst_insert_sort(t_list **head,
int (cmp)()); int (cmp)());
t_list *ft_lst_pop(t_list **lst); t_list *ft_lst_pop(t_list **lst);
char *ft_lst2str(t_list *list);
#endif #endif

View file

@ -17,7 +17,7 @@
# define STDIN STDIN_FILENO # define STDIN STDIN_FILENO
# define STDOUT STDOUT_FILENO # define STDOUT STDOUT_FILENO
# define STDERR STDERR_FILENO # define STDERR STDERR_FILENO
# define STDBUG 3 # define STDBUG 9
# define PIPE_READ 0 # define PIPE_READ 0
# define PIPE_WRITE 1 # define PIPE_WRITE 1

View file

@ -0,0 +1,25 @@
#include "libft.h"
char *ft_lst2str(t_list *list)
{
size_t size;
t_list *tmp;
char *new;
size = 0;
tmp = list;
while (tmp)
{
size += ft_strlen((char *)tmp->content) + 1;
tmp = tmp->next;
}
new = ft_memalloc(size);
while (list)
{
ft_strcat(new, (char *)list->content);
if (list->next)
ft_strcat(new, " ");
list = list->next;
}
return (new);
}