From bddc2d153a4c47257740a0bf0651513058a612d5 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 11 Oct 2019 16:38:41 +0200 Subject: Added and renamed files --- printer.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 printer.c (limited to 'printer.c') diff --git a/printer.c b/printer.c new file mode 100644 index 0000000..1484165 --- /dev/null +++ b/printer.c @@ -0,0 +1,42 @@ +#include +#include "ft_printf.h" + +void ft_putchar(char c) +{ + write(STDOUT_FILENO, &c, 1); +} + +void ft_putstr(char *str) +{ + while (*str) + write(STDOUT_FILENO, str++, 1); +} + +void ft_putnbr(int n) +{ + unsigned int p_n; + + p_n = n; + if (n < 0) + { + ft_putchar('-'); + p_n = -n; + } + if (p_n > 9) + ft_putnbr(p_n / 10); + ft_putchar(p_n % 10 + '0'); +} + +void ft_putxnbr(unsigned int n, char *hex_symbols) +{ + if (n > 15) + ft_putxnbr(n / 16, hex_symbols); + ft_putchar(hex_symbols[n % 16]); +} + +void ft_putunbr(unsigned int n) +{ + if (n > 9) + ft_putunbr(n / 10); + ft_putchar(n % 10 + '0'); +} -- cgit