merge
This commit is contained in:
commit
eb4a8ed663
BIN
.execution.c.swp
BIN
.execution.c.swp
Binary file not shown.
BIN
builtins/.echo.c.swp
Normal file
BIN
builtins/.echo.c.swp
Normal file
Binary file not shown.
@ -6,7 +6,11 @@
|
||||
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/17 13:09:08 by erey-bet #+# #+# */
|
||||
<<<<<<< HEAD
|
||||
/* Updated: 2023/02/21 21:45:38 by cchauvet ### ########.fr */
|
||||
=======
|
||||
/* Updated: 2023/02/21 22:09:55 by erey-bet ### ########.fr */
|
||||
>>>>>>> 1fdc51a668e616de94c33d5b3b1e9cb51182916d
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -46,27 +50,28 @@ int check_argument(char *str, int *check, int i)
|
||||
}
|
||||
|
||||
|
||||
char *conca(char **strings)
|
||||
char *conca(char **strs)
|
||||
{
|
||||
int len;
|
||||
char *result;
|
||||
char *str;
|
||||
char *p;
|
||||
int i;
|
||||
|
||||
i = -1;
|
||||
while (strings[++i] != NULL)
|
||||
len += strlen(strings[i]);
|
||||
result = (char *) ft_calloc(len * 2 + 1, sizeof(char));
|
||||
if (result == NULL)
|
||||
len = 0;
|
||||
while (strs[++i] != NULL)
|
||||
len += strlen(strs[i]) + 2;
|
||||
str = (char *) ft_calloc(len + 1, sizeof(char));
|
||||
if (str == NULL)
|
||||
return NULL;
|
||||
i = 0;
|
||||
while (strings[i] != NULL)
|
||||
i = -1;
|
||||
while (strs[++i] != NULL)
|
||||
{
|
||||
ft_strncpy(result + ft_strlen(result), strings[i], ft_strlen(strings[i]));
|
||||
ft_strncpy(result + ft_strlen(result), " ", 1);
|
||||
i++;
|
||||
ft_strlcat(str, strs[i], ft_strlen(str) + ft_strlen(strs[i]) + 2);
|
||||
str[ft_strlen(str)] = ' ';
|
||||
}
|
||||
return (result);
|
||||
str[ft_strlen(str)] = '\0';
|
||||
return (str);
|
||||
}
|
||||
|
||||
|
||||
@ -86,5 +91,12 @@ int echo(int fd, char **strs)
|
||||
ft_putchar_fd(str[i++], fd);
|
||||
if (!check)
|
||||
write(fd, "\n", 1);
|
||||
free(str);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*int main(int argc, char *argv[])
|
||||
{
|
||||
echo(1, argv);
|
||||
return (0);
|
||||
}*/
|
||||
|
Loading…
Reference in New Issue
Block a user