-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_utils.c
62 lines (53 loc) · 1.74 KB
/
ft_utils.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cnascime <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/08/10 05:48:08 by cnascime #+# #+# */
/* Updated: 2022/08/11 05:11:21 by cnascime ### ########.fr */
/* */
/* ************************************************************************** */
#include "libftprintf.h"
#include "./libft/libft.h"
// Converts number to string, calculates and returns the size of said string.
int ft_putint(int number)
{
int places;
char *convert;
convert = ft_itoa(number);
places = ft_putstr_fd(1, convert);
free (convert);
return (places);
}
int ft_putunsint(unsigned int number)
{
int places;
char *convert;
convert = ft_utoa(number);
places = ft_putstr_fd(1, convert);
free (convert);
return (places);
}
int ft_puthex(char lettercase, int number)
{
int places;
char *convert;
convert = ft_htoa(lettercase, number);
places = ft_putstr_fd(1, convert);
free (convert);
return (places);
}
int ft_putpointer(unsigned long long number)
{
int places;
char *convert;
char *temp;
convert = ft_ptoa(number);
temp = ft_strjoin("0x", convert);
places = ft_putstr_fd(1, temp);
free (convert);
free (temp);
return (places);
}