-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_libft_utils.c
70 lines (61 loc) · 1.55 KB
/
ft_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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_libft_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ysoroko <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/01/05 15:18:25 by ysoroko #+# #+# */
/* Updated: 2021/01/13 15:28:28 by ysoroko ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_putchar_fd(char c, int fd)
{
write(fd, &c, sizeof(char));
}
void ft_putstr_fd(char *s, int fd)
{
int i;
i = 0;
if (!s)
return ;
while (s[i] != '\0')
{
ft_putchar_fd(s[i], fd);
i++;
}
}
size_t ft_strlen(const char *str)
{
size_t i;
if (!str)
return (0);
i = 0;
while (str[i])
i++;
return (i);
}
int ft_isdigit(int c)
{
if (c >= '0' && c <= '9')
return (!0);
return (0);
}
char *ft_strchr(const char *str, int c)
{
int i;
char *my_str;
if (!str)
return (0);
my_str = (char *)(str);
i = -1;
while (my_str[++i])
{
if (my_str[i] == c)
return (&(my_str[i]));
}
if (my_str[i] == c)
return (&(my_str[i]));
return (0);
}