ft_show_tab.c
This commit is contained in:
parent
d7c041eacf
commit
312a66ed73
|
@ -0,0 +1,76 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_show_tab.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tosuman </var/spool/mail/tosuman> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/31 02:42:07 by tosuman #+# #+# */
|
||||
/* Updated: 2023/03/31 02:42:08 by tosuman ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
|
||||
void ft_putchar(char c)
|
||||
{
|
||||
write(1, &c, 1);
|
||||
}
|
||||
|
||||
void ft_putnbr(int nb)
|
||||
{
|
||||
if (nb > 9)
|
||||
{
|
||||
ft_putnbr(nb / 10);
|
||||
ft_putchar(nb % 10 + '0');
|
||||
}
|
||||
else if (nb == INT_MIN)
|
||||
{
|
||||
ft_putnbr(nb / 10);
|
||||
ft_putnbr(-(nb % 10));
|
||||
}
|
||||
else if (nb < 0)
|
||||
{
|
||||
ft_putchar('-');
|
||||
ft_putnbr(-nb);
|
||||
}
|
||||
else
|
||||
ft_putchar(nb % 10 + '0');
|
||||
}
|
||||
|
||||
void ft_puts(char *str)
|
||||
{
|
||||
while (*str)
|
||||
ft_putchar(*str++);
|
||||
ft_putchar('\n');
|
||||
}
|
||||
|
||||
void ft_show_tab(struct s_stock_str *par)
|
||||
{
|
||||
while ((*par).str)
|
||||
{
|
||||
ft_puts(par->str);
|
||||
ft_putnbr(par->size);
|
||||
ft_putchar('\n');
|
||||
ft_puts((par)->copy);
|
||||
++par;
|
||||
}
|
||||
}
|
||||
|
||||
/* ////
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char *strs[4];
|
||||
t_stock_str *tab;
|
||||
|
||||
strs[0] = "First";
|
||||
strs[1] = "Second";
|
||||
strs[2] = "Third";
|
||||
tab = ft_strs_to_tab(3, strs);
|
||||
ft_show_tab(tab);
|
||||
return (0);
|
||||
}
|
||||
*/ ////
|
Loading…
Reference in New Issue