Error management on write for bonus part

This commit is contained in:
David Gailleton
2025-11-21 15:57:06 +01:00
parent 620054c92e
commit 3b9f024c3c
9 changed files with 81 additions and 35 deletions

View File

@@ -6,13 +6,12 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/17 11:56:36 by dgaillet #+# #+# */
/* Updated: 2025/11/20 14:40:30 by dgaillet ### ########lyon.fr */
/* Updated: 2025/11/21 15:31:35 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "ft_printf_bonus.h"
#include <unistd.h>
#include <stdlib.h>
int print_char(t_arg *arg, char c)
{
@@ -22,6 +21,8 @@ int print_char(t_arg *arg, char c)
count += print_chars(arg->padding - 1, ' ');
if (!arg->minus && arg->zero)
count += print_chars(arg->zero - 1, ' ');
count += write(1, &c, 1);
if (write(1, &c, 1) < 0)
return (-10000);
count++;
return (count);
}