commit
This commit is contained in:
@@ -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++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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++;
|
||||||
|
|||||||
Reference in New Issue
Block a user