-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat_spec_handler.c
More file actions
82 lines (70 loc) · 1.35 KB
/
format_spec_handler.c
File metadata and controls
82 lines (70 loc) · 1.35 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "main.h"
/**
* _print_char - Prints character to the standard output
* @c: Character to be printed
* Return: Amount of characters printed
*/
int _print_char(va_list c)
{
_write(va_arg(c, int));
return (1);
}
/**
* _print_string - Prints a string to standard output
* @str: String to be printed
* Return: Amount of characters printed
*/
int _print_string(va_list str)
{
int count = 0;
char *string;
string = va_arg(str, char *);
if (string == NULL)
string = "(null)";
while (string[count] != '\0')
{
_write(string[count]);
count++;
}
return (count);
}
/**
* _print_percent - Prints a percent ' % ' symbol
* @list: Arguments list of numbers
* Return: The printed character
*/
int _print_percent(__attribute__((unused))va_list list)
{
_write('%');
return (1);
}
/**
* _print_integer - Prints an integer
* @args: list of arguments
* Return: Will return the amount of characters printed.
*/
int _print_integer(va_list args)
{
int number_length;
number_length = _print_number(args);
return (number_length);
}
/**
* _unsigned_integer - Prints unsigned integers
* @args: arguments list
* Return: total count of the numbers
*/
int _unsigned_integer(va_list args)
{
unsigned int n;
n = va_arg(args, unsigned int);
if (n == 0)
{
return (_print_unsigned_number(n));
}
if (n < 1)
{
return (-1);
}
return (_print_unsigned_number(n));
}