This commit is contained in:
Etienne Rey-bethbeder 2023-02-21 16:03:08 +01:00
parent 4c45a2c603
commit a136a66522

View File

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/17 13:09:08 by erey-bet #+# #+# */
/* Updated: 2023/02/21 15:38:53 by erey-bet ### ########.fr */
/* Updated: 2023/02/21 16:02:09 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
@ -56,16 +56,14 @@ char *conca(char **strings)
i = -1;
while (strings[++i] != NULL)
len += strlen(strings[i]);
result = (char *) malloc(len * 2 + 1);
result = (char *) ft_calloc(len * 2 + 1, sizeof(char));
if (result == NULL)
return NULL;
p = result;
i = 0;
while (strings[i] != NULL)
{
ft_strncpy(p, strings[i], ft_strlen(strings[i]));
ft_strncpy(p, " ", 1);
p += strlen(strings[i]);
ft_strncpy(result + ft_strlen(result), strings[i], ft_strlen(strings[i]));
ft_strncpy(result + ft_strlen(result), " ", 1);
i++;
}
return (result);
@ -85,8 +83,14 @@ int echo(int fd, char **strs)
i++;
i = check_argument(str, &check, i);
while (str[i])
ft_putchar_fd(fd, str[i++]);
ft_putchar_fd(str[i++], fd);
if (!check)
write(fd, "\n", 1);
return (0);
}
int main(int argc, char *argv[])
{
echo(1, argv);
return (0);
}