maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
ft_print_unsigned_dec.c File Reference
#include "libft.h"
Include dependency graph for ft_print_unsigned_dec.c:

Go to the source code of this file.

Functions

int ft_num_len (unsigned int num)
 
char * ft_uitoa (unsigned int n)
 
int ft_print_unsigned_dec (unsigned int n)
 

Function Documentation

◆ ft_num_len()

int ft_num_len ( unsigned int  num)

Definition at line 15 of file ft_print_unsigned_dec.c.

16{
17 int len;
18
19 len = 0;
20 while (num != 0)
21 {
22 len++;
23 num = num / 10;
24 }
25 return (len);
26}

Referenced by ft_uitoa().

Here is the caller graph for this function:

◆ ft_print_unsigned_dec()

int ft_print_unsigned_dec ( unsigned int  n)

Definition at line 47 of file ft_print_unsigned_dec.c.

48{
49 int count;
50 char *num;
51
52 count = 0;
53 if (n == 0)
54 count += write(1, "0", 1);
55 else
56 {
57 num = ft_uitoa(n);
58 count += ft_print_str(num);
59 free(num);
60 }
61 return (count);
62}
char * ft_uitoa(unsigned int n)
int ft_print_str(char *str)

References ft_print_str(), and ft_uitoa().

Referenced by ft_formatssssss().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ft_uitoa()

char * ft_uitoa ( unsigned int  n)

Definition at line 28 of file ft_print_unsigned_dec.c.

29{
30 char *num;
31 int len;
32
33 len = ft_num_len(n);
34 num = (char *)malloc(sizeof(char) * (len + 1));
35 if (!num)
36 return (0);
37 num[len] = '\0';
38 while (n != 0)
39 {
40 num[len - 1] = n % 10 + 48;
41 n = n / 10;
42 len--;
43 }
44 return (num);
45}
int ft_num_len(unsigned int num)

References ft_num_len().

Referenced by ft_print_unsigned_dec().

Here is the call graph for this function:
Here is the caller graph for this function: