This commit is contained in:
Etienne Rey-bethbeder 2022-11-25 15:35:14 +01:00
parent 6478c2ab47
commit b7b7d5aa04
4 changed files with 8 additions and 27 deletions

View file

@ -6,12 +6,11 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/12 16:27:59 by erey-bet #+# #+# */
/* Updated: 2022/11/22 22:53:10 by erey-bet ### ########.fr */
/* Updated: 2022/11/25 15:34:18 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
#include <stdarg.h>
static int ft_is_format(const char c)
{
@ -19,7 +18,7 @@ static int ft_is_format(const char c)
|| c == 'u' || c == 'x' || c == 'X' || c == '%');
}
static int ft_post_character_bis(char format, va_list args)
static int ft_post_character(char format, va_list args)
{
int count;
@ -43,24 +42,6 @@ static int ft_post_character_bis(char format, va_list args)
return (count);
}
static int ft_post_character(char format, va_list args)
{
int count;
count = ft_post_character_bis(format, args);
if (count == -1)
{
ft_putstr("(null)");
count = 6;
}
else if (count == -2)
{
ft_putstr("(nil)");
count = 5;
}
return (count);
}
int ft_printf(const char *str, ...)
{
va_list args;

View file

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/26 16:31:10 by erey-bet #+# #+# */
/* Updated: 2022/11/21 19:31:17 by erey-bet ### ########.fr */
/* Updated: 2022/11/25 15:34:24 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,8 +14,8 @@
# define FT_PRINTF_H
# include <stddef.h>
# include <stdlib.h>
# include <unistd.h>
# include <stdarg.h>
int ft_printf(const char *str, ...);
void ft_putchar(char c);

View file

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/05 00:32:38 by erey-bet #+# #+# */
/* Updated: 2022/10/15 23:15:57 by erey-bet ### ########.fr */
/* Updated: 2022/11/25 15:30:49 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,7 +18,7 @@ int ft_putstr(char *s)
count = 0;
if (s == NULL)
return (-1);
return (ft_putstr("(null)"));
while (*s)
{
ft_putchar(*s);

View file

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/14 23:01:21 by erey-bet #+# #+# */
/* Updated: 2022/11/21 19:26:59 by erey-bet ### ########.fr */
/* Updated: 2022/11/25 15:29:24 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,7 +18,7 @@ int ft_putvd(void *v)
unsigned long u;
if (v == NULL)
return (-2);
return (ft_putstr("(nil)"));
u = (unsigned long)v;
count = 2;
ft_putstr("0x");