minishell
ft_put.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void ft_putchar_fd (char c, int fd)
 
void ft_putstr_fd (char *s, int fd)
 
void ft_putendl_fd (char *s, int fd)
 
void ft_putnbr_fd (int n, int fd)
 

Function Documentation

◆ ft_putchar_fd()

void ft_putchar_fd ( char  c,
int  fd 
)

Definition at line 16 of file ft_putchar_fd.c.

17 {
18  write(fd, &c, 1);
19 }
Here is the caller graph for this function:

◆ ft_putendl_fd()

void ft_putendl_fd ( char *  s,
int  fd 
)

Definition at line 15 of file ft_putendl_fd.c.

16 {
17  ft_putstr_fd(s, fd);
18  ft_putchar_fd('\n', fd);
19 }
void ft_putchar_fd(char c, int fd)
Definition: ft_putchar_fd.c:16
void ft_putstr_fd(char *s, int fd)
Definition: ft_putstr_fd.c:17
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ft_putnbr_fd()

void ft_putnbr_fd ( int  n,
int  fd 
)

Definition at line 48 of file ft_putnbr_fd.c.

49 {
50  char num_str_buf[NUM_STR_BUF_LEN];
51  int buf_pos;
52  long long_n;
53 
54  if (0 <= n && n <= 9)
55  {
56  ft_putchar_fd('0' + n, fd);
57  return ;
58  }
59  buf_pos = 0;
60  long_n = ft_absl(n);
61  while (long_n != 0)
62  {
63  num_str_buf[buf_pos++] = (long_n % 10) + '0';
64  long_n /= 10;
65  }
66  if (n < 0)
67  num_str_buf[buf_pos++] = '-';
68  num_str_buf[buf_pos] = '\0';
69  ft_putstr_fd(reverse_str(num_str_buf), fd);
70 }
static long ft_absl(long v)
Definition: ft_putnbr_fd.c:40
static char * reverse_str(char *str)
Definition: ft_putnbr_fd.c:18
#define NUM_STR_BUF_LEN
Definition: ft_putnbr_fd.c:16
Here is the call graph for this function:

◆ ft_putstr_fd()

void ft_putstr_fd ( char *  s,
int  fd 
)

Definition at line 17 of file ft_putstr_fd.c.

18 {
19  size_t length;
20 
21  if (s == NULL)
22  return ;
23  while (*s != '\0')
24  {
25  length = ft_strnlen(s, INT_MAX);
26  write(fd, s, length);
27  s += length;
28  }
29 }
size_t ft_strnlen(const char *str, size_t max_len)
Definition: ft_strnlen.c:16
Here is the call graph for this function:
Here is the caller graph for this function: