end of mandatory functions

This commit is contained in:
David Gailleton
2025-11-08 17:57:58 +01:00
parent 25a804847b
commit b603db3539
13 changed files with 486 additions and 2 deletions

38
ft_strjoin.c Normal file
View File

@@ -0,0 +1,38 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/06 13:52:21 by dgaillet #+# #+# */
/* Updated: 2025/11/06 13:56:29 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
char *str;
int i;
int j;
str = malloc(sizeof(char) * (ft_strlen(s1) + ft_strlen(s2) + 1));
if (!str)
return (NULL);
i = 0;
j = 0;
while (s1[i])
{
str[i] = s1[i];
i++;
}
while (s2[j])
{
str[i + j] = s2[j];
j++;
}
str[i + j] = '\0';
return (str);
}