-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_next_line_utils.c
50 lines (45 loc) · 1.38 KB
/
get_next_line_utils.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: deleusis <deleusis@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/26 17:33:49 by deleusis #+# #+# */
/* Updated: 2022/02/10 18:13:29 by deleusis ### ########.fr */
/* */
/* ************************************************************************** */
#include "get_next_line.h"
size_t ft_strlen(char *str)
{
size_t i;
i = 0;
while (str && str[i] != '\0')
{
i++;
}
return (i);
}
char *ft_strjoin(char *s1, char *s2)
{
char *str;
unsigned int i;
unsigned int j;
if (!s1 || !s2)
return (NULL);
i = -1;
j = -1;
str = malloc(sizeof(char) * (ft_strlen(s1) + ft_strlen(s2) + 1));
if (!str)
return (NULL);
while (s1[++i])
str[i] = s1[i];
while (s2[++j])
str[i + j] = s2[j];
str[i + j] = '\0';
if (s1)
free(s1);
if (s2)
free(s2);
return (str);
}