commit
This commit is contained in:
35
C_00/git/ex07/ft_putnbr.c
Normal file
35
C_00/git/ex07/ft_putnbr.c
Normal file
@@ -0,0 +1,35 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putnbr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/05 18:09:22 by gbaconni #+# #+# */
|
||||
/* Updated: 2021/08/06 11:48:21 by gbaconni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putnbr(int nb)
|
||||
{
|
||||
char str[10];
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
if (nb == 0)
|
||||
write(1, "0", 1);
|
||||
while (nb != 0)
|
||||
{
|
||||
str[i] = nb % 10 + '0';
|
||||
nb /= 10;
|
||||
i++;
|
||||
}
|
||||
while (i > 0)
|
||||
{
|
||||
--i;
|
||||
if (str[i] >= 48 && str[i] <= 57)
|
||||
write(1, &str[i], 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user