0
0
This commit is contained in:
2021-08-26 08:27:09 +02:00
parent 6de9119879
commit 3152606445
3 changed files with 7 additions and 4 deletions

Binary file not shown.

View File

@@ -69,11 +69,14 @@ char *ft_copy(char *str, int size)
{ {
char *result; char *result;
result = (char *) malloc((size + 1) * sizeof(char)); result = NULL;
if (size > 0) if (size > 0)
{
result = (char *) malloc((size + 1) * sizeof(char));
if (!result)
return (NULL);
ft_strncpy(result, str, size); ft_strncpy(result, str, size);
else }
result[0] = '\0';
return (result); return (result);
} }

View File

@@ -36,7 +36,7 @@ int main(int argc, char *argv[])
strs = ft_split(str, charset); strs = ft_split(str, charset);
printf("str=%s charset=%s (ft_split)\n", str, charset); printf("str=%s charset=%s (ft_split)\n", str, charset);
i = 0; i = 0;
while (strs[i][0] != '\0') while (strs[i])
{ {
printf("strs[%d] = %s\n", i, strs[i]); printf("strs[%d] = %s\n", i, strs[i]);
i++; i++;