53 lines
1.4 KiB
C
53 lines
1.4 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* get_next_line_utils.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: grobledo <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2023/05/05 20:41:39 by grobledo #+# #+# */
|
|
/* Updated: 2023/05/05 20:41:41 by grobledo ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
#include "libft.h"
|
|
|
|
size_t ft_strleng(const char *str)
|
|
{
|
|
size_t i;
|
|
|
|
i = 0;
|
|
while (str && str[i])
|
|
{
|
|
i++;
|
|
}
|
|
return (i);
|
|
}
|
|
|
|
char *ft_strjoing(char const *s1, char const *s2)
|
|
{
|
|
size_t i;
|
|
size_t j;
|
|
char *dest;
|
|
|
|
if (!s2)
|
|
return (NULL);
|
|
dest = ft_calloc ((ft_strleng(s1) + ft_strleng(s2) + 1), sizeof (char));
|
|
if (dest == 0)
|
|
return (NULL);
|
|
i = 0;
|
|
j = 0;
|
|
while (s2[j])
|
|
{
|
|
while (i < ft_strleng(s1))
|
|
{
|
|
dest[i] = s1[i];
|
|
i++;
|
|
}
|
|
while (j < ft_strleng(s2))
|
|
{
|
|
dest[i + j] = s2[j];
|
|
j++;
|
|
}
|
|
}
|
|
return (dest);
|
|
}
|