added functions to print strings and numbers with padding of choice
This commit is contained in:
parent
f88ff8a600
commit
8107a8aaf3
24
ft_putnbrpad.c
Normal file
24
ft_putnbrpad.c
Normal file
@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putnbrpad.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2018/07/31 13:51:17 by tmaze #+# #+# */
|
||||
/* Updated: 2018/07/31 14:04:43 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void ft_putnbrpad(int nbr, size_t size, char pad, char align)
|
||||
{
|
||||
if (align == 'd')
|
||||
while (size-- != 0)
|
||||
ft_putchar(pad);
|
||||
ft_putnbr(nbr);
|
||||
if (align == 'g')
|
||||
while (size-- != 0)
|
||||
ft_putchar(pad);
|
||||
}
|
24
ft_putstrpad.c
Normal file
24
ft_putstrpad.c
Normal file
@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putstrpad.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2018/07/31 13:36:56 by tmaze #+# #+# */
|
||||
/* Updated: 2018/07/31 14:05:41 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void ft_putstrpad(char *str, size_t size, char pad, char align)
|
||||
{
|
||||
if (align == 'd')
|
||||
while (size-- != 0)
|
||||
ft_putchar(pad);
|
||||
ft_putstr(str);
|
||||
if (align == 'g')
|
||||
while (size-- != 0)
|
||||
ft_putchar(pad);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user