style: reoarginsed the file and fix the makefile
This commit is contained in:
parent
ecd9608320
commit
a5fe7484a1
46 changed files with 140 additions and 49 deletions
18
print/ft_putchar_fd.c
Normal file
18
print/ft_putchar_fd.c
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putchar_fd.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:58:22 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/10 15:31:57 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void ft_putchar_fd(char c, int fd)
|
||||
{
|
||||
write(fd, &c, 1);
|
||||
}
|
||||
19
print/ft_putendl_fd.c
Normal file
19
print/ft_putendl_fd.c
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putendl_fd.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:59:01 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/10 15:57:53 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void ft_putendl_fd(char *s, int fd)
|
||||
{
|
||||
ft_putstr_fd(s, fd);
|
||||
ft_putchar_fd('\n', fd);
|
||||
}
|
||||
55
print/ft_putnbr_fd.c
Normal file
55
print/ft_putnbr_fd.c
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putnbr_fd.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:59:18 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/13 20:13:20 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
static int ft_check_sign(int n, char *str, size_t *i, int fd)
|
||||
{
|
||||
size_t modulus;
|
||||
short int maiboyerlpb;
|
||||
|
||||
maiboyerlpb = 0;
|
||||
modulus = 1000000000;
|
||||
if (n < 0)
|
||||
{
|
||||
n = -n;
|
||||
str[(*i)] = '-';
|
||||
(*i)++;
|
||||
}
|
||||
while (modulus != 0)
|
||||
{
|
||||
if (n / modulus != 0 || maiboyerlpb != 0)
|
||||
{
|
||||
str[(*i)++] = (n / modulus) + 48;
|
||||
maiboyerlpb++;
|
||||
}
|
||||
n %= modulus;
|
||||
modulus /= 10;
|
||||
}
|
||||
ft_putstr_fd(str, fd);
|
||||
return (n);
|
||||
}
|
||||
|
||||
void ft_putnbr_fd(int n, int fd)
|
||||
{
|
||||
size_t i;
|
||||
char str[13];
|
||||
|
||||
i = 0;
|
||||
ft_bzero(str, 13);
|
||||
if (n == 0)
|
||||
ft_putstr_fd("0", fd);
|
||||
else if (n == -2147483648)
|
||||
ft_putstr_fd("-2147483648", fd);
|
||||
else
|
||||
ft_check_sign(n, str, &i, fd);
|
||||
}
|
||||
18
print/ft_putstr_fd.c
Normal file
18
print/ft_putstr_fd.c
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putstr_fd.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:58:46 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/10 15:57:46 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void ft_putstr_fd(char *s, int fd)
|
||||
{
|
||||
write(fd, s, ft_strlen(s));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue