-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.c
More file actions
63 lines (53 loc) · 1.44 KB
/
Copy pathutils.c
File metadata and controls
63 lines (53 loc) · 1.44 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alesferr <alesferr@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/07/20 18:44:49 by alesferr #+# #+# */
/* Updated: 2026/07/26 12:00:54 by alesferr ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
size_t ft_strlen(const char *s)
{
size_t i;
i = 0;
while (s[i])
i++;
return (i);
}
int ft_streq(const char *a, const char *b)
{
int i;
i = 0;
while (a[i] && a[i] == b[i])
i++;
return (a[i] == b[i]);
}
void ft_putstr_fd(const char *s, int fd)
{
write(fd, s, ft_strlen(s));
}
void ft_putnbr_fd(long n, int fd)
{
char c;
if (n < 0)
{
write(fd, "-", 1);
n = -n;
}
if (n >= 10)
ft_putnbr_fd(n / 10, fd);
c = '0' + (n % 10);
write(fd, &c, 1);
}
int ft_isqrt(int n)
{
int r;
r = 1;
while (r * r <= n)
r++;
return (r - 1);
}