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

Go to the source code of this file.

Functions

int ft_hex_len (unsigned int n)
 
void ft_put_hex (unsigned int n, const char upper_lower)
 
int ft_print_unsigned_hex (unsigned int n, const char upper_lower)
 

Function Documentation

◆ ft_hex_len()

int ft_hex_len ( unsigned int  n)

Definition at line 15 of file ft_print_unsigned_hex.c.

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

Referenced by ft_print_unsigned_hex().

Here is the caller graph for this function:

◆ ft_print_unsigned_hex()

int ft_print_unsigned_hex ( unsigned int  n,
const char  upper_lower 
)

Definition at line 49 of file ft_print_unsigned_hex.c.

50{
51 if (n == 0)
52 {
53 ft_putchar_fd('0', 1);
54 return (1);
55 }
56 else
57 ft_put_hex(n, upper_lower);
58 return (ft_hex_len(n));
59}
int ft_hex_len(unsigned int n)
void ft_put_hex(unsigned int n, const char upper_lower)
void ft_putchar_fd(char c, int fd)

References ft_hex_len(), ft_put_hex(), and ft_putchar_fd().

Referenced by ft_formatssssss().

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

◆ ft_put_hex()

void ft_put_hex ( unsigned int  n,
const char  upper_lower 
)

Definition at line 28 of file ft_print_unsigned_hex.c.

29{
30 if (n >= 16)
31 {
32 ft_put_hex(n / 16, upper_lower);
33 ft_put_hex(n % 16, upper_lower);
34 }
35 else
36 {
37 if (n <= 9)
38 ft_putchar_fd((n + '0'), 1);
39 else
40 {
41 if (upper_lower == 'x')
42 ft_putchar_fd((n - 10 + 'a'), 1);
43 if (upper_lower == 'X')
44 ft_putchar_fd((n - 10 + 'A'), 1);
45 }
46 }
47}

References ft_put_hex(), and ft_putchar_fd().

Referenced by ft_print_unsigned_hex(), and ft_put_hex().

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