-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lsttomtx.c
37 lines (34 loc) · 1.25 KB
/
ft_lsttomtx.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lsttomtx.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sebasnadu <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/11 16:46:35 by sebasnadu #+# #+# */
/* Updated: 2024/02/11 16:57:47 by sebasnadu ### ########.fr */
/* */
/* ************************************************************************** */
#include "../../include/libft.h"
char **ft_lsttomatrix(t_list *lst)
{
char **mtx;
t_list *tmp;
int len;
int i;
if (!lst)
return (NULL);
len = ft_lstsize(lst);
mtx = (char **)malloc(sizeof(char *) * (len + 1));
if (!mtx)
return (NULL);
tmp = lst;
i = -1;
while (tmp)
{
mtx[++i] = ft_strdup(tmp->content);
tmp = tmp->next;
}
mtx[len] = NULL;
return (mtx);
}