-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrite_struct.c
33 lines (30 loc) · 1004 Bytes
/
write_struct.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
** EPITECH PROJECT, 2023
** write_struct
** File description:
** Placeholder
*/
#include <unistd.h>
#include <stdarg.h>
#include <stdlib.h>
#include "include/my.h"
int write_struct(to_print_t to_print)
{
int count = 0;
if (to_print.space == ' ')
count += write(1, " ", 1);
if (to_print.left_pad != 0 && to_print.left_pad[0] == ' ')
count += write(1, to_print.left_pad, my_strlen(to_print.left_pad));
if (to_print.sign == '+')
count += write(1, "+", 1);
if (to_print.sign == '-')
count += write(1, "-", 1);
if (to_print.alt_form != 0)
count += write(1, to_print.alt_form, my_strlen(to_print.alt_form));
if (to_print.left_pad != 0 && to_print.left_pad[0] == '0')
count += write(1, to_print.left_pad, my_strlen(to_print.left_pad));
count += write(1, to_print.arg, my_strlen(to_print.arg));
if (to_print.right_pad != 0)
count += write(1, to_print.right_pad, my_strlen(to_print.right_pad));
return count;
}