Libft aortigos

This commit is contained in:
Angel Ortigosa Perez
2025-11-15 09:18:35 +01:00
commit c87ab67280
45 changed files with 1439 additions and 0 deletions

40
ft_strjoin.c Normal file
View File

@@ -0,0 +1,40 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/03 19:39:00 by aortigos #+# #+# */
/* Updated: 2023/10/03 19:47:34 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
char *x;
size_t c1;
size_t c2;
size_t i;
i = 0;
c1 = 0;
c2 = 0;
if (s1 == NULL || s2 == NULL)
return (NULL);
x = (char *)malloc(sizeof(char) * ft_strlen(s1) + ft_strlen(s2) + 1);
if (!(x))
return (NULL);
while (c1 != ft_strlen(s1))
{
x[i++] = s1[c1++];
}
while (c2 != ft_strlen(s2))
{
x[i++] = s2[c2++];
}
x[i] = '\0';
return (x);
}