-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint_funcs.c
73 lines (63 loc) · 1.24 KB
/
print_funcs.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
73
#include "main.h"
/**
* print_char - Prints character
* @vl: list of arguments
* Return: Number of characters printed.
*/
int print_char(va_list vl)
{
_putchar(va_arg(vl, int));
return (1);
}
/**
* print_string - Prints a string
* @vl: list of arguments
* Return: Number of characters printed.
*/
int print_string(va_list vl)
{
int a;
char *str;
str = va_arg(vl, char *);
if (str == NULL)
str = "(null)";
for (a = 0; str[a] != '\0'; a++)
_putchar(str[a]);
return (a);
}
/**
* print_percent_sign - Prints the percent sign
* @vl: list of arguments
* Return: Number of characters printed.
*/
int print_percent_sign(__attribute__((unused))va_list vl)
{
_putchar('%');
return (1);
}
/**
* print_integer - Prints an integer
* @vl: list of arguments
* Return: Number of characters printed.
*/
int print_integer(va_list vl)
{
int num_length;
num_length = print_number(vl);
return (num_length);
}
/**
* print_unsigned_integer - Prints Unsigned integers
* @vl: list of arguments
* Return: Number of characters printed
*/
int print_unsigned_integer(va_list vl)
{
unsigned int num;
num = va_arg(vl, unsigned int);
if (num == 0)
return (print_unsigned_number(num));
if (num < 1)
return (-1);
return (print_unsigned_number(num));
}