commit
This commit is contained in:
64
C_08/git/ex05/ft_show_tab.c
Normal file
64
C_08/git/ex05/ft_show_tab.c
Normal file
@@ -0,0 +1,64 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_show_tab.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/25 10:17:09 by gbaconni #+# #+# */
|
||||
/* Updated: 2021/08/25 12:05:50 by gbaconni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "ft_stock_str.h"
|
||||
|
||||
void ft_putstr(char *str)
|
||||
{
|
||||
while (*str != '\0')
|
||||
write(1, str++, 1);
|
||||
}
|
||||
|
||||
void ft_putnbr(int nb)
|
||||
{
|
||||
char c;
|
||||
|
||||
if (nb < 0)
|
||||
{
|
||||
nb *= -1;
|
||||
write(1, "-", 1);
|
||||
}
|
||||
if (nb >= 0 && nb <= 9)
|
||||
{
|
||||
c = nb + '0';
|
||||
write(1, &c, 1);
|
||||
}
|
||||
else if (nb == -2147483648)
|
||||
{
|
||||
ft_putnbr((nb / 10) * -1);
|
||||
ft_putnbr((nb % 10) * -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ft_putnbr(nb / 10);
|
||||
ft_putnbr(nb % 10);
|
||||
}
|
||||
}
|
||||
|
||||
void ft_show_tab(struct s_stock_str *par)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (par && par[i].size > 0)
|
||||
{
|
||||
ft_putstr(par[i].str);
|
||||
ft_putstr("\n");
|
||||
ft_putnbr(par[i].size);
|
||||
ft_putstr("\n");
|
||||
ft_putstr(par[i].copy);
|
||||
ft_putstr("\n");
|
||||
i++;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user