ft_lst2str
This commit is contained in:
parent
a0d85d1c71
commit
5ebb9848b1
5 changed files with 28 additions and 1 deletions
|
|
@ -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
libftasm/STDBUG
Normal file
0
libftasm/STDBUG
Normal 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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
25
libftasm/srcs/lst/ft_lst2str.c
Normal file
25
libftasm/srcs/lst/ft_lst2str.c
Normal 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);
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue