-
Notifications
You must be signed in to change notification settings - Fork 0
/
libf2.c
63 lines (55 loc) · 1.58 KB
/
libf2.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* libf2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zwalad <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/08/03 19:14:33 by zwalad #+# #+# */
/* Updated: 2022/08/22 22:22:22 by zwalad ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int pr_strchr(char *str, int c)
{
int i;
i = 0;
while (str[i] != (char)c)
{
if (str[i] == '\0')
{
return (0);
}
i++;
}
return (i);
}
int pr_isalnum(int c)
{
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')
|| (c >= 'A' && c <= 'Z'))
{
return (1);
}
return (0);
}
int pr_strncmpp(char *str1, char *str2)
{
size_t i;
if (pr_strlen(str1) != pr_strlen(str2))
return (2);
i = 0;
while (str1[i] == str2[i] && str1[i] && str2[i])
i++;
return (str1[i] - str2[i]);
}
int ft_strncmp(char *str1, char *str2, size_t n)
{
size_t i;
if (n == 0)
return (0);
i = 0;
while (i < (n - 1) && str1[i] == str2[i] && str1[i] && str2[i])
i++;
return (str1[i] - str2[i]);
}