Archived
1
0

finished printf

This commit is contained in:
2023-11-22 14:08:30 +01:00
parent 173696d21e
commit 3b77e54d40
10 changed files with 27 additions and 8 deletions

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/17 16:48:37 by adjoly #+# #+# */
/* Updated: 2023/11/22 13:01:29 by adjoly ### ########.fr */
/* Updated: 2023/11/22 14:01:50 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,7 +19,7 @@ int ft_putaddr(void *ptr)
if (ptr == NULL)
return (write(1, "(nil)", 5));
write(1, "0x", 2);
r = ft_putnbrbase((long unsigned int)ptr, "0123456789abcdef");
r = ft_putnbrbase_p((long unsigned int)ptr, "0123456789abcdef");
return (2 + r);
}

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/17 16:50:36 by adjoly #+# #+# */
/* Updated: 2023/11/22 11:24:27 by adjoly ### ########.fr */
/* Updated: 2023/11/22 14:00:38 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -23,7 +23,9 @@ int ft_putnbrulong(unsigned int n);
int ft_putaddr(void *ptr);
int ft_putstr(char *s);
int ft_putnbrbase(unsigned long int n, char *base);
int ft_putnbrbase_p(unsigned long int n, char *base);
int ft_putnbrbase(unsigned int n, char *base);
int ft_putchar(char c);
int ft_putnbr(int n);
size_t ft_strlen(const char *s);

BIN
ft_printf.o Normal file

Binary file not shown.

BIN
ft_putchar.o Normal file

Binary file not shown.

BIN
ft_putnbr.o Normal file

Binary file not shown.

View File

@ -6,15 +6,15 @@
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/18 10:57:44 by adjoly #+# #+# */
/* Updated: 2023/11/22 13:21:55 by adjoly ### ########.fr */
/* Updated: 2023/11/22 14:02:37 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_putnbrbase(unsigned long int n, char *base)
int ft_putnbrbase(unsigned int n, char *base)
{
unsigned long int base_len;
unsigned int base_len;
int len;
len = 0;
@ -28,3 +28,20 @@ int ft_putnbrbase(unsigned long int n, char *base)
}
return (len);
}
int ft_putnbrbase_p(unsigned long int n, char *base)
{
unsigned long int base_len;
int len;
len = 0;
base_len = (int)ft_strlen(base);
if (n < base_len)
len += write(1, &base[n % base_len], 1);
else
{
len += ft_putnbrbase_p(n / base_len, base);
len += write(1, &base[n % base_len], 1);
}
return (len);
}

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.