init
This commit is contained in:
49
C/c08v1/ex05/ft_show_tab.c
Normal file
49
C/c08v1/ex05/ft_show_tab.c
Normal file
@ -0,0 +1,49 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_show_tab.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/27 18:54:39 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/08/03 17:28:11 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
#include "ft_stock_str.h"
|
||||
|
||||
void ft_putchar(char c)
|
||||
{
|
||||
write(1, &c, 1);
|
||||
}
|
||||
|
||||
void ft_print_str(char *str)
|
||||
{
|
||||
while (*str != 0)
|
||||
write(1, str++, 1);
|
||||
ft_putchar('\n');
|
||||
}
|
||||
|
||||
void ft_print_nbr(int nbr)
|
||||
{
|
||||
if (nbr > 9)
|
||||
{
|
||||
ft_print_nbr(nbr / 10);
|
||||
ft_print_nbr(nbr % 10);
|
||||
}
|
||||
else
|
||||
ft_putchar(nbr + 48);
|
||||
}
|
||||
|
||||
void ft_show_tab(struct s_stock_str *par)
|
||||
{
|
||||
while (par->str[0] != 0)
|
||||
{
|
||||
ft_print_str(par->str);
|
||||
ft_print_nbr(par->size);
|
||||
ft_putchar('\n');
|
||||
ft_print_str(par->copy);
|
||||
par++;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user