-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibrary.c
More file actions
80 lines (68 loc) · 1.01 KB
/
library.c
File metadata and controls
80 lines (68 loc) · 1.01 KB
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
71
72
73
74
75
76
77
78
79
80
#include "ds.h"
void ft_putchar(char c)
{
write(1, &c, 1);
}
void newline(void)
{
write(1, "\n", 1);
}
int ft_strlen(const char *str)
{
int i;
i = 0;
while (str[i])
i++;
return (i);
}
void ft_putstr(char *str)
{
int i;
i = 0;
while (str[i])
i++;
write(1, str, i);
}
void ft_putnbr_recursive(long nb, char *str, int *len)
{
if (nb > 9)
ft_putnbr_recursive(nb / 10, str, len);
str[(*len)++] = nb % 10 + 48;
}
void ft_putnbr(long nb, char *str, int *len)
{
if (!nb)
{
write(1, "0", 1);
return ;
}
if (nb < 0)
{
write(1, "-", 1);
nb = -nb;
}
ft_putnbr_recursive(nb, str, len);
str[*len] = '\n';
write(1, str, *len + 1);
}
int ft_strcmp(const char *s1, const char *s2)
{
while (*s1 && (*s1 == *s2))
{
s1++;
s2++;
}
return (*s1 - *s2);
}
int ft_isdigit(int c)
{
return (c >= ZERO && c <= NINE);
}
int tok_issign(t_tok_type c)
{
return (c == TOK_DIV || c == TOK_MULT || c == TOK_PLUS || c == TOK_MINUS);
}
int tok_isparen(t_tok_type c)
{
return (c == TOK_LPAREN || c == TOK_RPAREN);
}