Archived
1
0
This commit is contained in:
2023-11-22 13:34:16 +01:00
parent 8020f614af
commit 822d3a75d3
12 changed files with 18 additions and 16 deletions

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */ /* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/17 16:48:37 by adjoly #+# #+# */ /* Created: 2023/11/17 16:48:37 by adjoly #+# #+# */
/* Updated: 2023/11/20 16:09:16 by adjoly ### ########.fr */ /* Updated: 2023/11/22 13:01:29 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -16,12 +16,14 @@ int ft_putaddr(void *ptr)
{ {
int r; int r;
if (ptr == NULL)
return (write(1, "(nil)", 5));
write(1, "0x", 2); write(1, "0x", 2);
r = ft_putnbrbase((long unsigned int)ptr, "0123456789abcdef"); r = ft_putnbrbase((long unsigned int)ptr, "0123456789abcdef");
return (2 + r); return (2 + r);
} }
int ft_putnbrulong(unsigned long n) int ft_putnbrulong(unsigned int n)
{ {
int len; int len;
@ -46,17 +48,17 @@ int ft_printconversion(char conversion, va_list args)
else if (conversion == 's') else if (conversion == 's')
count = ft_putstr(va_arg(args, char *)); count = ft_putstr(va_arg(args, char *));
else if (conversion == 'c') else if (conversion == 'c')
count = ft_putchar(va_arg(args, char *)[0]); count = ft_putchar(va_arg(args, int));
else if (conversion == 'i' || conversion == 'd') else if (conversion == 'i' || conversion == 'd')
count = ft_putnbr(va_arg(args, int)); count = ft_putnbr(va_arg(args, int));
else if (conversion == 'u') else if (conversion == 'u')
count = ft_putnbrulong(va_arg(args, unsigned long)); count = ft_putnbrulong(va_arg(args, unsigned int));
else if (conversion == 'p') else if (conversion == 'p')
count = ft_putaddr(va_arg(args, void *)); count = ft_putaddr(va_arg(args, void *));
else if (conversion == 'x') else if (conversion == 'x')
count = ft_putnbrbase(va_arg(args, unsigned int), "0123456789abcdef"); count = ft_putnbrbase(va_arg(args, unsigned long), "0123456789abcdef");
else if (conversion == 'X') else if (conversion == 'X')
count = ft_putnbrbase(va_arg(args, unsigned int), "0123456789ABCDEF"); count = ft_putnbrbase(va_arg(args, unsigned long), "0123456789ABCDEF");
return (count); return (count);
} }

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */ /* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/17 16:50:36 by adjoly #+# #+# */ /* Created: 2023/11/17 16:50:36 by adjoly #+# #+# */
/* Updated: 2023/11/20 15:52:59 by adjoly ### ########.fr */ /* Updated: 2023/11/22 11:24:27 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,11 +19,11 @@
int ft_printf(const char *format, ...); int ft_printf(const char *format, ...);
int ft_printconversion(char conversion, va_list args); int ft_printconversion(char conversion, va_list args);
int ft_putnbrulong(unsigned long n); int ft_putnbrulong(unsigned int n);
int ft_putaddr(void *ptr); int ft_putaddr(void *ptr);
int ft_putstr(char *s); int ft_putstr(char *s);
int ft_putnbrbase(int n, char *base); int ft_putnbrbase(unsigned long int n, char *base);
int ft_putchar(char c); int ft_putchar(char c);
int ft_putnbr(int n); int ft_putnbr(int n);
size_t ft_strlen(const char *s); size_t ft_strlen(const char *s);

BIN
ft_printf.o Normal file

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */ /* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/18 10:49:00 by adjoly #+# #+# */ /* Created: 2023/11/18 10:49:00 by adjoly #+# #+# */
/* Updated: 2023/11/20 15:51:04 by adjoly ### ########.fr */ /* Updated: 2023/11/22 11:07:22 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

BIN
ft_putchar.o Normal file

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */ /* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/31 11:52:46 by adjoly #+# #+# */ /* Created: 2023/10/31 11:52:46 by adjoly #+# #+# */
/* Updated: 2023/11/20 16:00:22 by adjoly ### ########.fr */ /* Updated: 2023/11/22 10:51:24 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -20,7 +20,7 @@ int ft_putnbr(int n)
len = 0; len = 0;
if (n < 0) if (n < 0)
{ {
write(1, "-", 1); len += write(1, "-", 1);
nbr = -n; nbr = -n;
} }
else else

BIN
ft_putnbr.o Normal file

Binary file not shown.

View File

@ -6,15 +6,15 @@
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */ /* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/18 10:57:44 by adjoly #+# #+# */ /* Created: 2023/11/18 10:57:44 by adjoly #+# #+# */
/* Updated: 2023/11/20 16:16:34 by adjoly ### ########.fr */ /* Updated: 2023/11/22 13:21:55 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "ft_printf.h" #include "ft_printf.h"
int ft_putnbrbase(int n, char *base) int ft_putnbrbase(unsigned long int n, char *base)
{ {
int base_len; unsigned long int base_len;
int len; int len;
len = 0; len = 0;

BIN
ft_putnbrbase.o Normal file

Binary file not shown.

BIN
ft_putstr.o Normal file

Binary file not shown.

BIN
ft_strlen.o Normal file

Binary file not shown.

BIN
libftprintf.a Normal file

Binary file not shown.