-
Notifications
You must be signed in to change notification settings - Fork 0
/
print_tools.c
61 lines (54 loc) · 1.53 KB
/
print_tools.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* print_tools.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: oel-ouar <oel-ouar@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/24 14:23:07 by oel-ouar #+# #+# */
/* Updated: 2021/10/24 17:48:52 by oel-ouar ### ########.fr */
/* */
/* ************************************************************************** */
# include "parsing.h"
size_t ft_strlen(const char *s)
{
size_t n;
n = 0;
while (s[n] != '\0')
n++;
return (n);
}
int ft_strncmp(const char *str1, const char *str2, size_t n)
{
while (n--)
{
if (*str1 == '\0' && *str2 == '\0')
return (0);
if (*str1 != *str2)
return ((unsigned char)*str1 - (unsigned char)*str2);
str1++;
str2++;
}
return (0);
}
void ft_putchar_fd(char c, int fd)
{
write(fd, &c, 1);
}
void ft_putstr_fd(char *s, int fd)
{
if (s == NULL)
return ;
while (*s != '\0')
{
ft_putchar_fd(*s, fd);
s++;
}
}
void ft_putendl_fd(char *s, int fd)
{
if (s == NULL)
return ;
ft_putstr_fd(s, fd);
ft_putchar_fd('\n', fd);
}