mirror of
https://github.com/DavidGailleton/42-ft_printf.git
synced 2026-11-01 11:42:03 +01:00
some fix on printf
This commit is contained in:
1 parent
b0a77bc18c
commit
b620f5ecdb
12 files changed
+58
-45
No files matched your search
+6
-5
@@ -42,10 +42,12 @@ int ft_printf(const char *first_arg, ...)
|
||||
int i;
|
||||
int temp;
|
||||
|
||||
if (!first_arg)
|
||||
return (-1);
|
||||
nb_print = 0;
|
||||
va_start(args, first_arg);
|
||||
i = 0;
|
||||
while (first_arg[i])
|
||||
i = -1;
|
||||
while (first_arg[++i])
|
||||
{
|
||||
temp = nb_print;
|
||||
if (first_arg[i] == '%' && first_arg[i + 1] != '\0')
|
||||
@@ -53,11 +55,10 @@ int ft_printf(const char *first_arg, ...)
|
||||
i++;
|
||||
nb_print += ft_print_arg(first_arg[i], args);
|
||||
}
|
||||
else
|
||||
else if (first_arg[i] != '%')
|
||||
nb_print += write(1, &first_arg[i], 1);
|
||||
if (temp > nb_print)
|
||||
if (temp >= nb_print)
|
||||
return (-1);
|
||||
i++;
|
||||
}
|
||||
va_end(args);
|
||||
return (nb_print);
|
||||
|
||||
Reference in new issue
Block a user