end of mandatory functions
This commit is contained in:
38
ft_strjoin.c
Normal file
38
ft_strjoin.c
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user