-
Notifications
You must be signed in to change notification settings - Fork 0
/
format_specifiers.c
72 lines (63 loc) · 1.32 KB
/
format_specifiers.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
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
#include "main.h"
/**
* print_char - Prints character
* @list: list of arguments
* Return: Will return the amount of characters printed.
*/
int print_char(va_list list)
{
_write_char(va_arg(list, int));
return (1);
}
/**
* print_string - Prints a string
* @list: list of arguments
* Return: Will return the amount of characters printed.
*/
int print_string(va_list list)
{
int i;
char *str;
str = va_arg(list, char *);
if (str == NULL)
str = "(null)";
for (i = 0; str[i] != '\0'; i++)
_write_char(str[i]);
return (i);
}
/**
* print_percent - Prints a percent symbol
* @list: list of arguments
* Return: Will return the amount of characters printed.
*/
int print_percent(__attribute__((unused))va_list list)
{
_write_char('%');
return (1);
}
/**
* print_integer - Prints an integer
* @list: list of arguments
* Return: Will return the amount of characters printed.
*/
int print_integer(va_list list)
{
int num_length;
num_length = print_number(list);
return (num_length);
}
/**
* unsigned_integer - Prints Unsigned integers
* @list: List of all of the argumets
* Return: a count of the numbers
*/
int unsigned_integer(va_list list)
{
unsigned int num;
num = va_arg(list, unsigned int);
if (num == 0)
return (print_unsgined_number(num));
if (num < 1)
return (-1);
return (print_unsgined_number(num));
}