1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
get_next_line/get_next_line_utils.c

62 lines
1.5 KiB
C
Raw Normal View History

2023-12-01 23:05:16 +01:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/01 17:12:02 by adjoly #+# #+# */
/* Updated: 2023/12/01 22:31:36 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "get_next_line.h"
size_t ft_strlen(char *s)
{
size_t i;
i = 0;
while (s[i])
i++;
return (i);
}
size_t ft_strlen_til_nl(char *s)
{
size_t i;
i = 0;
while (s[i] && s[i] != '\n')
i++;
return (i);
}
char *ft_strjoin(char *s1, char *s2)
{
char *result;
size_t i;
size_t j;
i = 0;
j = 0;
if (s1 == NULL && s2 == NULL)
return (NULL);
result = malloc((ft_strlen(s1) + ft_strlen(s2) + 1) * sizeof(char));
if (result == NULL)
return (NULL);
while (s1[i])
{
result[i] = s1[i];
i++;
}
while (s2[j])
{
result[i] = s2[j];
i++;
j++;
}
result[i] = '\0';
return (result);
}