-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunc_aux.c
83 lines (76 loc) · 1.77 KB
/
func_aux.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* func_aux.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rnarciso <rnarciso@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/06 06:49:13 by rnarciso #+# #+# */
/* Updated: 2022/12/10 08:06:43 by rnarciso ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
size_t ft_strlen(const char *s)
{
size_t i;
i = 0;
while (s)
i++;
return (i);
}
char *ft_strncpy(char *dest, char *src, unsigned int n)
{
unsigned int i;
i = 0;
while (i < n && src[i] != '\0')
{
dest[i] = src[i];
i++;
}
while (i < n)
{
dest[i] = '\0';
i++;
}
return (dest);
}
unsigned long ft_plus_ultra(unsigned long n, unsigned long len)
{
if (n >= 10)
{
len = ft_plus_ultra(n / 10, len);
ft_putchar((n % 10) + '0');
len++;
}
else
{
ft_putchar((n % 10) + '0');
len++;
}
return (len);
}
unsigned long ft_put_nbr(long long n, unsigned long len)
{
if (n == LONG_MIN)
{
write (1, "-9223372036854775808", 20);
return (len = 20);
}
if (n < 0)
{
ft_putchar('-');
len++;
n = -n;
}
if (n > 9)
{
len = ft_put_nbr(n / 10, len);
len = ft_put_nbr(n % 10, len);
}
if (n < 10 && n >= 0)
{
ft_putchar(n + '0');
len++;
}
return (len);
}