-
Notifications
You must be signed in to change notification settings - Fork 0
/
libft_utils.c
52 lines (46 loc) · 1.4 KB
/
libft_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
51
52
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* libft_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rghouzra <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/21 15:23:07 by rghouzra #+# #+# */
/* Updated: 2022/11/21 15:23:10 by rghouzra ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractal.h"
int ft_strncmp(const char *s1, const char *s2, size_t n)
{
size_t i;
unsigned char *str1;
unsigned char *str2;
str1 = (unsigned char *)s1;
str2 = (unsigned char *)s2;
i = 0;
while (str1[i] && str2[i] && i < n)
{
if (!((str1[i]) == str2[i]))
{
return (str1[i] - str2[i]);
}
i++;
}
if (i == n)
{
return (0);
}
return (str1[i] - str2[i]);
}
int ft_strlen(char *s)
{
int i;
i = 0;
while (*(s + i))
i++;
return (i);
}
void ft_putstr(char *s, int fd)
{
write(fd, s, ft_strlen(s));
}