-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.c
executable file
·64 lines (54 loc) · 1.6 KB
/
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
53
54
55
56
57
58
59
60
61
62
63
64
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abenheni <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/14 20:15:17 by abenheni #+# #+# */
/* Updated: 2023/05/14 20:15:18 by abenheni ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int ft_strcmp(char *s1, char *s2)
{
int i;
i = 0;
while (s1[i] && s2[i] && s1[i] == s2[i])
i++;
return (s1[i] - s2[i]);
}
int ft_strncmp(const char *str1, const char *str2, size_t n)
{
size_t i;
i = 0;
if (n == 0)
return (0);
while ((str1[i] && str2[i]) && (str1[i] == str2[i]) && i < n - 1)
i++;
return ((unsigned char)str1[i] - (unsigned char)str2[i]);
}
int ft_isalnum(int c)
{
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')
|| (c >= 'A' && c <= 'Z') || c == '_')
return (1);
return (0);
}
int ft_strlen(char *str)
{
int i;
if (!str)
return (0);
i = 0;
while (str[i])
i++;
return (i);
}
void ft_putstr(char *str)
{
int i;
i = 0;
while (str[i])
write(1, &str[i++], 1);
}