65 lines
1.5 KiB
C
65 lines
1.5 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_show_tab.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2024/06/20 17:02:05 by whaffman #+# #+# */
|
|
/* Updated: 2024/06/22 11:47:30 by whaffman ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include <unistd.h>
|
|
#include "ft_stock_str.h"
|
|
|
|
void ft_putnbr(int nb)
|
|
{
|
|
char c;
|
|
|
|
if (-2147483648 == nb)
|
|
{
|
|
write(1, "-2147483648", 11);
|
|
}
|
|
else if (nb >= 0 && nb <= 9)
|
|
{
|
|
c = nb + '0';
|
|
write(1, &c, 1);
|
|
}
|
|
else if (nb < 0)
|
|
{
|
|
write(1, "-", 1);
|
|
ft_putnbr(-nb);
|
|
}
|
|
else if (nb > 9)
|
|
{
|
|
ft_putnbr(nb / 10);
|
|
ft_putnbr(nb % 10);
|
|
}
|
|
}
|
|
|
|
void ft_putstr(char *str)
|
|
{
|
|
int i;
|
|
|
|
i = 0;
|
|
while (str[i])
|
|
{
|
|
i++;
|
|
}
|
|
write(1, str, i);
|
|
write(1, "\n", 1);
|
|
}
|
|
|
|
void ft_show_tab(struct s_stock_str *par)
|
|
{
|
|
while (par->str)
|
|
{
|
|
ft_putstr(par->str);
|
|
ft_putnbr(par->size);
|
|
write(1, "\n", 1);
|
|
ft_putstr(par->copy);
|
|
par++;
|
|
}
|
|
}
|