/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strs_to_tab.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: cchauvet #include "ft_stock_str.h" int ft_strlen(char *str) { int i; i = 0; while (str[i] != 0) i++; return (i); } char *ft_strdup(char *src) { int i; char *dest; dest = malloc(sizeof(*dest) * ft_strlen(src)); i = 0; while (src[i] != 0) { dest[i] = src[i]; i++; } dest[i] = 0; return (dest); } t_stock_str *ft_strs_to_tab(int ac, char **av) { int i; t_stock_str *tab; tab = malloc(sizeof(*tab) * (ac + 1)); i = 0; while (i < ac) { tab[i].size = ft_strlen(av[i]); tab[i].str = av[i]; tab[i].copy = ft_strdup(av[i]); i++; } tab[i].str = ""; return (tab); }