-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_next_line_utils_bonus.c
71 lines (63 loc) · 1.61 KB
/
get_next_line_utils_bonus.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line_utils_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abouchfa <abouchfa@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/17 13:29:55 by abouchfa #+# #+# */
/* Updated: 2021/11/21 15:12:39 by abouchfa ### ########.fr */
/* */
/* ************************************************************************** */
#include "get_next_line_bonus.h"
size_t ft_strlen(const char *s)
{
size_t i;
i = 0;
while (s[i])
i++;
return (i);
}
char *ft_strjoin(char const *s1, char const *s2)
{
int i;
int j;
size_t size;
char *res;
if (!s1 || !s2)
return (NULL);
size = ft_strlen((char *) s1) + ft_strlen((char *) s2) + 1;
res = malloc(sizeof(char) * size);
if (!res)
return (NULL);
i = 0;
j = 0;
while (s1[j])
res[i++] = s1[j++];
j = 0;
while (s2[j])
res[i++] = s2[j++];
res[i] = 0;
return (res);
}
int gnl_strchr(const char *s)
{
if (s)
{
while (*s)
{
if (*s == '\n')
return (1);
s++;
}
}
return (0);
}
void ft_strncpy(char *dest, char *src, int size)
{
int i;
i = -1;
while (++i < size)
dest[i] = src[i];
dest[i] = 0;
}