aboutsummaryrefslogtreecommitdiff
path: root/c08/ex05
diff options
context:
space:
mode:
Diffstat (limited to 'c08/ex05')
-rw-r--r--c08/ex05/ft_show_tab.c57
-rw-r--r--c08/ex05/ft_stock_str.h23
2 files changed, 80 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++;
+ }
+}
diff --git a/c08/ex05/ft_stock_str.h b/c08/ex05/ft_stock_str.h
new file mode 100644
index 0000000..2ce09f4
--- /dev/null
+++ b/c08/ex05/ft_stock_str.h
@@ -0,0 +1,23 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_stock_str.h :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/07/08 16:54:59 by cacharle #+# #+# */
+/* Updated: 2019/07/11 14:14:13 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#ifndef FT_STOCK_STR_H
+# define FT_STOCK_STR_H
+
+typedef struct s_stock_str
+{
+ int size;
+ char *str;
+ char *copy;
+} t_stock_str;
+
+#endif