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

Go to the source code of this file.

Functions

int ft_formatssssss (va_list args, const char format)
 
int ft_printf (const char *str,...)
 

Function Documentation

◆ ft_formatssssss()

int ft_formatssssss ( va_list  args,
const char  format 
)

Definition at line 15 of file ft_printf.c.

16{
17 int len;
18
19 len = 0;
20 if (format == 'c')
21 len += ft_print_char(va_arg(args, int));
22 else if (format == 's')
23 len += ft_print_str(va_arg(args, char *));
24 else if (format == 'p')
25 len += ft_print_ptr(va_arg(args, unsigned long long));
26 else if (format == 'd' || format == 'i')
27 len += ft_print_int(va_arg(args, int));
28 else if (format == 'u')
29 len += ft_print_unsigned_dec(va_arg(args, unsigned int));
30 else if (format == 'x' || format == 'X')
31 len += ft_print_unsigned_hex(va_arg(args, unsigned int), format);
32 else if (format == '%')
33 len += ft_print_percent();
34 return (len);
35}
int ft_print_ptr(unsigned long long ptr)
int ft_print_percent(void)
int ft_print_str(char *str)
int ft_print_char(int c)
int ft_print_unsigned_hex(unsigned int num, const char format)
int ft_print_unsigned_dec(unsigned int n)
int ft_print_int(int n)

References ft_print_char(), ft_print_int(), ft_print_percent(), ft_print_ptr(), ft_print_str(), ft_print_unsigned_dec(), and ft_print_unsigned_hex().

Referenced by ft_printf().

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

◆ ft_printf()

int ft_printf ( const char *  str,
  ... 
)

Definition at line 37 of file ft_printf.c.

38{
39 int i;
40 va_list args;
41 int len;
42
43 i = 0;
44 len = 0;
45 va_start(args, str);
46 while (str[i])
47 {
48 if (str[i] == '%')
49 {
50 len += ft_formatssssss(args, str[i + 1]);
51 i++;
52 }
53 else
54 len += ft_print_char(str[i]);
55 i++;
56 }
57 va_end(args);
58 return (len);
59}
int ft_formatssssss(va_list args, const char format)
Definition ft_printf.c:15

References ft_formatssssss(), and ft_print_char().

Referenced by append_word_if_valid(), env_tests(), ft_print_2d_arr(), initialise(), input_error_checks(), main(), new_process(), pipe_tests(), print_ast_args(), print_ast_node(), print_env(), print_env_stack(), print_maxishell(), print_stack(), print_t_env(), print_tokens(), test_get_env(), test_init_env(), test_set_env(), and test_unset_env().

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