-
Notifications
You must be signed in to change notification settings - Fork 0
/
char_check_functions.c
61 lines (55 loc) · 1.49 KB
/
char_check_functions.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* char_check_functions.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: agraetz <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/15 10:17:09 by anniegraetz #+# #+# */
/* Updated: 2022/03/31 12:09:27 by agraetz ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ifchar(char c)
{
ft_putchar_fd(c, 1);
return (1);
}
int ifstr(va_list ap)
{
char *str;
str = va_arg(ap, char *);
if (!str)
{
ft_putstr_fd("(null)", 1);
return (6);
}
ft_putstr_fd(str, 1);
return (ft_strlen(str));
}
int ifhexdec(size_t n, char c)
{
int count;
count = numlength(n, 16);
if (c == 'p')
{
ft_putstr_fd("0x", 1);
count += 2;
c = 'x';
}
if (n >= 16)
{
ifhexdec(n / 16, c);
ifhexdec(n % 16, c);
}
else
{
if (n < 10)
ft_putchar_fd(n + 48, 1);
else if (c == 'x')
ft_putchar_fd(n + 87, 1);
else
ft_putchar_fd(n + 55, 1);
}
return (count);
}