-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_opt.c
More file actions
100 lines (79 loc) · 1.43 KB
/
_opt.c
File metadata and controls
100 lines (79 loc) · 1.43 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "main.h"
/**
* print_buffer - check code.
* @format : variable
* Return: check declaration
*/
int print_buffer(const char *format)
{
write(1, format, 1);
return (1);
}
/**
* print_char - check code.
* @arg_ptr : variable
* Return: check the declaration
*/
int print_char(va_list arg_ptr)
{
char buffer_1_byte;
buffer_1_byte = va_arg(arg_ptr, int);
write(1, &buffer_1_byte, 1);
return (1);
}
/**
* print_string - check code.
* @arg_ptr : variable
* Return: check description
*/
int print_string(va_list arg_ptr)
{
char *buffer_1_byte;
int i;
char *nl = "(null)";
buffer_1_byte = va_arg(arg_ptr, char *);
if (buffer_1_byte == NULL)
buffer_1_byte = nl;
i = 0;
while (*(buffer_1_byte + i) != '\0')
{
write(1, buffer_1_byte + i, 1);
i++;
}
return (i);
}
/**
* print_percent - check code.
* @arg_ptr : variable
* Return: check declaration
*/
int print_percent(va_list arg_ptr)
{
char buffer_1_byte;
(void) arg_ptr;
buffer_1_byte = '%';
write(1, &buffer_1_byte, 1);
return (1);
}
/**
* print_number - Print an integer to the standard output.
* @num: Variable argument list.
* @i: Variable argument list.
* Return: Number of characters printed.
*/
int print_number(unsigned int num, int i)
{
int exp;
char cum;
exp = 1;
while (num / exp > 9)
exp = exp * 10;
while (exp != 0)
{
cum = '0' + num / exp;
i = i + write(1, &cum, 1);
num = num % exp;
exp = exp / 10;
}
return (i);
}