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

Go to the source code of this file.

Functions

int ft_ptr_len (uintptr_t num)
 
void ft_put_ptr (uintptr_t num)
 
int ft_print_ptr (unsigned long long ptr)
 

Function Documentation

◆ ft_print_ptr()

int ft_print_ptr ( unsigned long long  ptr)

Definition at line 44 of file ft_print_ptr.c.

45{
46 int print_length;
47
48 print_length = 0;
49 if (ptr == 0)
50 print_length += write(1, "(nil)", 5);
51 else
52 {
53 print_length += write(1, "0x", 2);
54 ft_put_ptr(ptr);
55 print_length += ft_ptr_len(ptr);
56 }
57 return (print_length);
58}
void ft_put_ptr(uintptr_t num)
int ft_ptr_len(uintptr_t num)

References ft_ptr_len(), and ft_put_ptr().

Referenced by ft_formatssssss().

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

◆ ft_ptr_len()

int ft_ptr_len ( uintptr_t  num)

Definition at line 15 of file ft_print_ptr.c.

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

Referenced by ft_print_ptr().

Here is the caller graph for this function:

◆ ft_put_ptr()

void ft_put_ptr ( uintptr_t  num)

Definition at line 28 of file ft_print_ptr.c.

29{
30 if (num >= 16)
31 {
32 ft_put_ptr(num / 16);
33 ft_put_ptr(num % 16);
34 }
35 else
36 {
37 if (num <= 9)
38 ft_putchar_fd((num + '0'), 1);
39 else
40 ft_putchar_fd((num - 10 + 'a'), 1);
41 }
42}
void ft_putchar_fd(char c, int fd)

References ft_put_ptr(), and ft_putchar_fd().

Referenced by ft_print_ptr(), and ft_put_ptr().

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