aboutsummaryrefslogtreecommitdiff
path: root/c08/ex05/ft_show_tab.c
diff options
context:
space:
mode:
Diffstat (limited to 'c08/ex05/ft_show_tab.c')
-rw-r--r--c08/ex05/ft_show_tab.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/c08/ex05/ft_show_tab.c b/c08/ex05/ft_show_tab.c
new file mode 100644
index 0000000..4af1843
--- /dev/null
+++ b/c08/ex05/ft_show_tab.c
@@ -0,0 +1,57 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_show_tab.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/07/11 15:55:41 by cacharle #+# #+# */
+/* Updated: 2019/07/14 11:12:21 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include <unistd.h>
+#include "ft_stock_str.h"
+
+void ft_putchar(char c)
+{
+ write(1, &c, 1);
+}
+
+void ft_putnbr(int nb)
+{
+ unsigned int p_nb;
+
+ p_nb = nb;
+ if (nb < 0)
+ {
+ write(1, "-", 1);
+ p_nb = -nb;
+ }
+ if (p_nb > 9)
+ ft_putnbr(p_nb / 10);
+ ft_putchar(p_nb % 10 + '0');
+}
+
+void ft_putstr(char *str)
+{
+ while (*str)
+ write(1, str++, 1);
+}
+
+void ft_show_tab(struct s_stock_str *par)
+{
+ int i;
+
+ i = 0;
+ while (par[i].str != 0)
+ {
+ ft_putstr(par[i].str);
+ write(1, "\n", 1);
+ ft_putnbr(par[i].size);
+ write(1, "\n", 1);
+ ft_putstr(par[i].copy);
+ write(1, "\n", 1);
+ i++;
+ }
+}