mirror of
https://github.com/Ladebeze66/Piscine42.git
synced 2026-11-09 21:27:16 +01:00
Piscine42
This commit is contained in:
72
C08/ex05/ft_show_tab.c
Executable file
72
C08/ex05/ft_show_tab.c
Executable file
@@ -0,0 +1,72 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_show_tab.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/12/21 10:43:27 by fgras-ca #+# #+# */
|
||||
/* Updated: 2022/12/21 11:44:58 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
#include "ft_stock_str.h"
|
||||
|
||||
struct s_stock_str *ft_strs_to_tab(int ac, char **av);
|
||||
|
||||
void ft_putchar(char c)
|
||||
{
|
||||
write(1, &c, 1);
|
||||
}
|
||||
|
||||
void ft_putstr(char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (str[i] != '\0')
|
||||
{
|
||||
write(1, &str[i], 1);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void ft_putnbr(int nb)
|
||||
{
|
||||
if (nb == -2147483648)
|
||||
{
|
||||
write(1, "-2147483648", 11);
|
||||
}
|
||||
else if (nb >= 0 && nb < 10)
|
||||
{
|
||||
ft_putchar(nb + 48);
|
||||
}
|
||||
else if (nb < 0)
|
||||
{
|
||||
ft_putchar('-');
|
||||
ft_putnbr(nb * (-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[i].str)
|
||||
{
|
||||
ft_putstr(par[i].str);
|
||||
ft_putchar('\n');
|
||||
ft_putnbr(par[i].size);
|
||||
ft_putchar('\n');
|
||||
ft_putstr(par[i].copy);
|
||||
ft_putchar('\n');
|
||||
i++;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user