-
Notifications
You must be signed in to change notification settings - Fork 0
/
print_utlis_3.c
63 lines (56 loc) · 1.64 KB
/
print_utlis_3.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* print_utlis_3.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sfathima <sfathima@student.42abudhabi +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/14 15:44:15 by sfathima #+# #+# */
/* Updated: 2021/11/14 16:54:50 by sfathima ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_strcmp(char *s1, char *s2)
{
int i;
i = 0;
while (s1[i] != '\0')
{
if (s1[i] != s2[i])
return (s1[i] - s2[i]);
i++;
}
return (s1[i] - s2[i]);
}
int ft_isdigit(int i)
{
if (i >= '0' && i <= '9')
return (1);
return (0);
}
int ft_arg_plus(va_list ap, int ct, char c)
{
int x;
x = va_arg(ap, int);
if (x < 0)
{
ct = ft_print_int(x, ct);
return (ct);
}
else if (c == '+')
ct = ft_print_char('+', ct);
else
ct = ft_print_char(' ', ct);
ct = ft_print_int(x, ct);
return (ct);
}
int ft_arg_space(va_list ap, int ct, char c, char d)
{
if (d == 'd' || d == 'i')
ct = ft_arg_plus(ap, ct, c);
else if (d == 's' && !(ft_isdigit(c)))
ct = ft_print_str(va_arg(ap, char *), ct);
else
ct = ft_print_char(' ', ct);
return (ct);
}