Compare commits

..

No commits in common. "03a2cc055c171c30caf66ae3f02f7f08b28279e0" and "0ece156b974b5c69f1ed0933ca4a5ca310bb373c" have entirely different histories.

View File

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