-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_next_line_utils.c
More file actions
58 lines (52 loc) · 1.56 KB
/
get_next_line_utils.c
File metadata and controls
58 lines (52 loc) · 1.56 KB
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
51
52
53
54
55
56
57
58
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: esobrinh <esobrinh@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/18 14:42:09 by esobrinh #+# #+# */
/* Updated: 2022/10/21 23:19:14 by esobrinh ### ########.fr */
/* */
/* ************************************************************************** */
#include "get_next_line.h"
size_t ft_strlen(const char *str)
{
int i;
i = 0;
while (str && str[i] != '\0')
i++;
return (i);
}
char *ft_strjoin(char const *s1, char const *s2)
{
int i;
char *p;
int len1;
int len2;
len1 = ft_strlen(s1);
len2 = ft_strlen(s2);
p = (char *)malloc(len1 + len2 + 1);
if (!p)
return (NULL);
i = -1;
while (s1 && s1[++i])
p[i] = s1[i];
i = -1;
while (s2 && s2[++i])
{
p[len1] = s2[i];
len1++;
}
p[len1] = '\0';
free ((char *)s1);
return (p);
}
char *ft_strchr(const char *str, int c)
{
while (str != NULL && (*str != '\0') && (*str != (unsigned char)c))
str++;
if (str && *str == (unsigned char)c)
return ((char *)str);
return (NULL);
}