-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprint_flag_7.c
More file actions
49 lines (43 loc) · 933 Bytes
/
Copy pathprint_flag_7.c
File metadata and controls
49 lines (43 loc) · 933 Bytes
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "main.h"
/**
* print_plus - print the flag '+' for positive numbers
* @num: the number to print
* @len: pointer to the length counter
*/
void print_plus(int num, int *len)
{
if (num >= 0)
*len += _putchar('+');
print_number(num, len);
}
/**
* print_space - print a space before a number if it is positive
* @num: the number to print
* @len: pointer to the lenght counter
*/
void print_space(int num, int *len)
{
if (num >= 0)
*len += _putchar(' ');
print_number(num, len);
}
/**
* print_prefix - print a prefix before the number if it's non-zero
* @num: the number to print
* @c: the conversion specifier
* @len: pointer to the length counter
*/
void print_prefix(int num, char c, int *len)
{
if (num != 0)
{
if (c == 'o')
*len += _putchar('0');
else if (c == 'x' || 'X')
*len += _putstr("0x");
}
if (c == 'o')
print_octal_number(num, len);
else
print_hex_number(num, c, len);
}