diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-07-15 08:15:37 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-07-15 08:15:37 +0200 |
| commit | 3b9a1d7dcc5683b962f2bf24795e80e1c449cd1f (patch) | |
| tree | 25b02c02f5140dbefbabd7720f292d8be3d5cc51 /c08/ex05 | |
| parent | c2bf9fcefbb4453cee271ccd1af9674ad2f3a181 (diff) | |
| download | piscine-3b9a1d7dcc5683b962f2bf24795e80e1c449cd1f.tar.gz piscine-3b9a1d7dcc5683b962f2bf24795e80e1c449cd1f.tar.bz2 piscine-3b9a1d7dcc5683b962f2bf24795e80e1c449cd1f.zip | |
c07 passed, c08 in progress, rush01(+ 6x6 try)
Diffstat (limited to 'c08/ex05')
| -rw-r--r-- | c08/ex05/ft_show_tab.c | 57 | ||||
| -rw-r--r-- | c08/ex05/ft_stock_str.h | 23 |
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 |
