-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathso_long_libft_utils.c
More file actions
65 lines (58 loc) · 1.47 KB
/
so_long_libft_utils.c
File metadata and controls
65 lines (58 loc) · 1.47 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
59
60
61
62
63
64
65
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* so_long_libft_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: opopov <opopov@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/24 15:28:27 by opopov #+# #+# */
/* Updated: 2025/02/24 15:30:34 by opopov ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
int ft_strlen(char *str)
{
int i;
i = 0;
if (!str)
return (-1);
while (str[i] != '\0' && str[i] != '\n')
i++;
return (i);
}
int ft_strcmp(const char *s1, const char *s2)
{
size_t a;
a = 0;
while (s1[a] && s2[a])
{
if (s1[a] != s2[a])
{
return ((unsigned char)s1[a] - (unsigned char)s2[a]);
}
a++;
}
return (0);
}
char *ft_strrchr(const char *s, int c)
{
int a;
a = 0;
while (s[a] != '\0')
{
a++;
}
if (c == '\0')
{
return ((char *)&s[a]);
}
while (a >= 0)
{
if (s[a] == (char) c)
{
return ((char *)&s[a]);
}
a--;
}
return (NULL);
}