-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_printf_utils.c
56 lines (48 loc) · 1.49 KB
/
ft_printf_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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: monoue <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/07/28 17:07:49 by monoue #+# #+# */
/* Updated: 2020/08/20 12:47:03 by monoue ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_putchar(char c)
{
write(STDOUT_FILENO, &c, 1);
}
void ft_putstr(char *str)
{
write(STDOUT_FILENO, str, ft_strlen(str));
}
size_t ft_strlen(const char *str)
{
size_t len;
if (!str)
return (0);
len = 0;
while (str[len])
len++;
return (len);
}
char *ft_strchr(const char *s, int c)
{
unsigned char uc;
size_t index;
uc = (unsigned char)c;
index = 0;
while (s[index] != uc && s[index] != '\0')
index++;
if (s[index] == uc)
return ((char *)(s + index));
return (NULL);
}
bool ft_isdigit(const unsigned int c)
{
if (c >= '0' && c <= '9')
return (true);
return (false);
}