aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--parse.c0
-rw-r--r--printer.c42
-rw-r--r--utils.c41
4 files changed, 43 insertions, 42 deletions
diff --git a/Makefile b/Makefile
index 30bbc8c..a469ebc 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ CCFLAGS = -Wall -Wextra #-Werror
RM = rm -f
NAME = ft_printf
-SRC = ft_printf.c utils.c
+SRC = ft_printf.c utils.c printer.c parse.c
OBJ = $(SRC:.c=.o)
INCLUDE = ft_printf.h
diff --git a/parse.c b/parse.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/parse.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 <unistd.h>
+#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');
+}
diff --git a/utils.c b/utils.c
index 1484165..8b13789 100644
--- a/utils.c
+++ b/utils.c
@@ -1,42 +1 @@
-#include <unistd.h>
-#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');
-}