-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0-functions.c
72 lines (65 loc) · 1010 Bytes
/
0-functions.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"
/**
* _putchar - prints a character
* @c: character to be printed
* Return: character
*/
int _putchar(char c)
{
return (write(1, &c, 1));
}
/**
* print_char - prints a character
* @list: contains arguments
* Return: length
*/
int print_char(va_list list)
{
int c = va_arg(list, int);
_putchar(c);
return (1);
}
/**
* print_string - prints string
* @list: contains arguments
* Return: length
*/
int print_string(va_list list)
{
int i;
char *c = va_arg(list, char *);
if (c == NULL)
c = "(null)";
for (i = 0; c[i] != '\0'; i++)
_putchar(c[i]);
return (i);
}
/**
* print_perc - prints %
* @list: contains arguments
* Return: length
*/
int print_perc(va_list list)
{
(void)list;
_putchar('%');
return (1);
}
/**
* print_rev - reverse string
* @list: contains arguments
* Return: length
*/
int print_rev(va_list list)
{
char *s = va_arg(list, char *);
int i = str_len(s);
int x = i;
i--;
while (i >= 0)
{
_putchar(s[i]);
i--;
}
return (x);
}