it works
This commit is contained in:
parent
607a121ced
commit
80f0b560ce
3 changed files with 22 additions and 22 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/11/01 12:31:58 by kcolin #+# #+# */
|
||||
/* Updated: 2024/11/06 17:37:39 by kcolin ### ########.fr */
|
||||
/* Updated: 2024/11/08 15:04:19 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -34,24 +34,21 @@ char *ft_strjoin(char *s1, char *s2)
|
|||
if (s1 == NULL)
|
||||
{
|
||||
s1 = malloc(1);
|
||||
if (s1 == NULL)
|
||||
return (NULL);
|
||||
s1[0] = '\0';
|
||||
}
|
||||
out = malloc(ft_strlen(s1) + ft_strlen(s2) + 1);
|
||||
if (out == NULL)
|
||||
return (NULL);
|
||||
i = 0;
|
||||
j = 0;
|
||||
while (s1[i] != '\0')
|
||||
{
|
||||
i = -1;
|
||||
j = -1;
|
||||
while (s1[++i] != '\0')
|
||||
out[i] = s1[i];
|
||||
i++;
|
||||
}
|
||||
while (s2[j] != '\0')
|
||||
{
|
||||
out[i] = s2[j];
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
while (s2[++j] != '\0')
|
||||
out[i++] = s2[j];
|
||||
out[i] = '\0';
|
||||
free(s1);
|
||||
return (out);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue