0
0
This commit is contained in:
2021-08-25 19:53:46 +02:00
parent 70fea93f32
commit 8d276ad189
2 changed files with 5 additions and 3 deletions

View File

@@ -53,7 +53,7 @@ struct s_stock_str *ft_strs_to_tab(int ac, char **av)
while (i < ac) while (i < ac)
{ {
result[i].size = ft_strlen(av[i]); result[i].size = ft_strlen(av[i]);
result[i].str = av[i]; result[i].str = ft_strdup(av[i]);
result[i].copy = ft_strdup(av[i]); result[i].copy = ft_strdup(av[i]);
i++; i++;
} }

View File

@@ -14,8 +14,9 @@
#include "ft_stock_str.h" #include "ft_stock_str.h"
struct s_stock_str *ft_strs_to_tab(int ac, char **av); struct s_stock_str *ft_strs_to_tab(int ac, char **av);
char *ft_strdup(char *src);
int main(int argc, char **argv) int main(int argc, char *argv[])
{ {
t_stock_str *result; t_stock_str *result;
int i; int i;
@@ -27,10 +28,11 @@ int main(int argc, char **argv)
argv[i] = argv[i + 1]; argv[i] = argv[i + 1];
i++; i++;
} }
argv[i] = NULL;
argc--; argc--;
result = ft_strs_to_tab(argc, argv); result = ft_strs_to_tab(argc, argv);
i = 0; i = 0;
while (result[i].size > 0) while (result && result[i].size > 0)
{ {
printf("result[%d] = { size=%d, str=%s, copy=%s}\n", i, result[i].size, result[i].str, result[i].copy); printf("result[%d] = { size=%d, str=%s, copy=%s}\n", i, result[i].size, result[i].str, result[i].copy);
i++; i++;