libft/str/ft_strjoin.c
Raphael 2cf0714dc7
docs(str): moving the actual documentation on the header
- The documentation on the header allow u to see on the files where the
header is inclued
2025-09-05 16:30:00 +02:00

40 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 13:55:15 by rparodi #+# #+# */
/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "str.h"
#include <stdlib.h>
char *ft_strjoin(char const *s1, char const *s2)
{
size_t i;
size_t save_i;
char *str;
i = 0;
str = (char *)malloc((ft_strlen(s1) + ft_strlen(s2)) + 1);
if (!str)
return (NULL);
while (s1[i] != '\0')
{
str[i] = s1[i];
i++;
}
save_i = i;
i = 0;
while (s2[i] != '\0')
{
str[save_i + i] = s2[i];
i++;
}
str[i + save_i] = '\0';
return (str);
}