copy on git

This commit is contained in:
Thomas Rieg 2025-11-28 19:50:58 +01:00
commit 42653de246
205 changed files with 7459 additions and 0 deletions

42
libft/ft_strjoin.c Executable file
View file

@ -0,0 +1,42 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thrieg <thrieg@student.42mulhouse.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/15 12:14:45 by thrieg #+# #+# */
/* Updated: 2025/02/16 19:04:47 by thrieg ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
//returns NULL if any argument is null or if an allocation fails
char *ft_strjoin(char const *s1, char const *s2)
{
char *ret;
int i;
int j;
if (!s1 || !s2)
return (NULL);
ret = malloc(sizeof(char) * (ft_strlen(s1) + ft_strlen(s2) + 1));
if (!ret)
return (NULL);
i = 0;
while (s1[i])
{
ret[i] = s1[i];
i++;
}
j = 0;
while (s2[j])
{
ret[i] = s2[j];
i++;
j++;
}
ret[i] = '\0';
return (ret);
}