OUAF OUAF OUAF OUAF OUAF BOUGNOUL
This commit is contained in:
parent
03a2cc055c
commit
1fdc51a668
@ -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 22:09:55 by erey-bet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -46,27 +46,28 @@ int check_argument(char *str, int *check, int i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *conca(char **strings)
|
char *conca(char **strs)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
char *result;
|
char *str;
|
||||||
char *p;
|
char *p;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = -1;
|
i = -1;
|
||||||
while (strings[++i] != NULL)
|
len = 0;
|
||||||
len += strlen(strings[i]);
|
while (strs[++i] != NULL)
|
||||||
result = (char *) ft_calloc(len * 2 + 1, sizeof(char));
|
len += strlen(strs[i]) + 2;
|
||||||
if (result == NULL)
|
str = (char *) ft_calloc(len + 1, sizeof(char));
|
||||||
|
if (str == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
i = 0;
|
i = -1;
|
||||||
while (strings[i] != NULL)
|
while (strs[++i] != NULL)
|
||||||
{
|
{
|
||||||
ft_strncpy(result + ft_strlen(result), strings[i], ft_strlen(strings[i]));
|
ft_strlcat(str, strs[i], ft_strlen(str) + ft_strlen(strs[i]) + 2);
|
||||||
ft_strncpy(result + ft_strlen(result), " ", 1);
|
str[ft_strlen(str)] = ' ';
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
return (result);
|
str[ft_strlen(str)] = '\0';
|
||||||
|
return (str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -86,11 +87,12 @@ int echo(int fd, char **strs)
|
|||||||
ft_putchar_fd(str[i++], fd);
|
ft_putchar_fd(str[i++], fd);
|
||||||
if (!check)
|
if (!check)
|
||||||
write(fd, "\n", 1);
|
write(fd, "\n", 1);
|
||||||
|
free(str);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
/*int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
echo(1, argv);
|
echo(1, argv);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}*/
|
||||||
|
Loading…
Reference in New Issue
Block a user