-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstring_op.c
73 lines (63 loc) · 1.64 KB
/
string_op.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
72
73
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* string_op.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: asarandi <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/14 23:47:10 by asarandi #+# #+# */
/* Updated: 2017/12/27 16:59:56 by asarandi ### ########.fr */
/* */
/* ************************************************************************** */
#include "filler.h"
size_t ft_strlen(char const *s)
{
size_t i;
i = 0;
while (s[i])
{
i++;
}
return (i);
}
void ft_putstr(char const *s)
{
size_t size;
size = ft_strlen(s);
write(1, s, size);
return ;
}
int ft_strnequ(char const *s1, char const *s2, size_t n)
{
if ((ft_strncmp(s1, s2, n)) == 0)
return (1);
return (0);
}
int ft_strncmp(const char *s1, const char *s2, size_t n)
{
size_t i;
i = 0;
while (i < n)
{
if ((unsigned char)s1[i] != (unsigned char)s2[i])
break ;
if ((!s1[i]) || (!s2[i]))
break ;
i++;
}
if (i == n)
return (0);
return ((unsigned char)s1[i] - (unsigned char)s2[i]);
}
char *ft_strcpy(char *dst, const char *src)
{
int i;
i = 0;
while (src[i])
{
dst[i] = src[i];
i++;
}
dst[i] = 0;
return (dst);
}