0
0
This commit is contained in:
Guy Baconniere
2021-08-20 10:02:38 +02:00
parent 5aa02c94b5
commit d30270c485
354 changed files with 0 additions and 0 deletions

40
C_04/git/ex02/ft_putnbr.c Normal file
View File

@@ -0,0 +1,40 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/13 09:24:02 by gbaconni #+# #+# */
/* Updated: 2021/08/16 13:26:12 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
#include <stdio.h>
void ft_putnbr(int nb)
{
char c;
if (nb < 0)
{
nb *= -1;
write(1, "-", 1);
}
if (nb >= 0 && nb <= 9)
{
c = nb + '0';
write(1, &c, 1);
}
else if (nb == -2147483648)
{
ft_putnbr((nb / 10) * -1);
ft_putnbr((nb % 10) * -1);
}
else
{
ft_putnbr(nb / 10);
ft_putnbr(nb % 10);
}
}

30
C_04/git/ex02/main.c Normal file
View File

@@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/13 09:22:26 by gbaconni #+# #+# */
/* Updated: 2021/08/13 11:18:57 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
void ft_putnbr(int nb);
int main(void)
{
int nb;
printf("Input Number: ");
scanf("%d", &nb);
ft_putnbr(nb);
write(1, "\n", 1);
printf("nb=%d (ft_putnbr)\n", nb);
return (0);
}

8
C_04/git/ex02/main.sh Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/sh
set -e
#norminette -R CheckForbiddenSourceHeader ft_*.c
norminette -R CheckForbiddenSourceHeader
gcc -Wall -Wextra -Werror -o a.out *.c
echo $(basename $PWD):
./a.out
rm -f a.out