blob: 67a0304c82d57c7717151106ddc5c33ead919a5c (
plain)
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
38
39
40
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strs_to_tab.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/07/07 17:15:32 by cacharle #+# #+# */
/* Updated: 2019/07/08 17:10:21 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "ft_stock_str.h"
struct s_stock_str *ft_strs_to_tab(int ac, char **av)
{
int i;
char *copy;
t_stock_str tmp_stock;
t_stock_str *strs_stocks
strs_stocks = malloc(sizeof(t_stock_str) * ac);
while (ac-- > 0)
{
i = 0
while (av[ac][i])
i++;
tmp_stock = malloc(sizeof(t_stock_str));
tmp_stock->size = i;
tmp_stock->str = av[ac];
copy = malloc(sizeof(char) * i);
i = -1;
while (av[ac][i++])
copy[i] = av[ac][i];
tmp_stock->copy = copy;
strs_stocks[ac] = tmp_stock;
}
return (strs_stocks);
}
|