Archived
1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
libft/ft_strjoin.c
2023-11-13 17:04:34 +01:00

42 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 13:44:09 by adjoly #+# #+# */
/* Updated: 2023/11/12 16:18:45 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
char *result;
size_t i;
size_t j;
i = 0;
j = 0;
if (s1 == NULL || s2 == NULL)
return (NULL);
result = ft_calloc((ft_strlen(s1) + ft_strlen(s2) + 1), sizeof(char));
if (result == NULL)
return (NULL);
while (s1[i])
{
result[i] = s1[i];
i++;
}
while (s2[j])
{
result[i] = s2[j];
i++;
j++;
}
result[i] = '\0';
return (result);
}