mirror of
https://github.com/DavidGailleton/42-ft_printf.git
synced 2026-11-01 11:42:03 +01:00
fix: valgrind error when % at end of first printf arg
This commit is contained in:
1 parent
b6670f2400
commit
b0a77bc18c
2 files changed
+5
-5
No files matched your search
@@ -10,10 +10,10 @@
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
#include "ft_printf_bonus.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static int ft_print_arg_flags(t_arg *arg, va_list args)
|
||||
{
|
||||
@@ -84,7 +84,7 @@ int ft_printf(const char *first_arg, ...)
|
||||
while (first_arg[i])
|
||||
{
|
||||
temp = nb_print;
|
||||
if (first_arg[i] == '%')
|
||||
if (first_arg[i] == '%' && first_arg[i + 1] != '\0')
|
||||
{
|
||||
i++;
|
||||
nb_print += ft_print_arg((char *)&first_arg[i], args);
|
||||
|
||||
+2
-2
@@ -10,9 +10,9 @@
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_printf.h"
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
#include "ft_printf.h"
|
||||
|
||||
static int ft_print_arg(char c, va_list args)
|
||||
{
|
||||
@@ -48,7 +48,7 @@ int ft_printf(const char *first_arg, ...)
|
||||
while (first_arg[i])
|
||||
{
|
||||
temp = nb_print;
|
||||
if (first_arg[i] == '%')
|
||||
if (first_arg[i] == '%' && first_arg[i + 1] != '\0')
|
||||
{
|
||||
i++;
|
||||
nb_print += ft_print_arg(first_arg[i], args);
|
||||
|
||||
Reference in new issue
Block a user