-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprintf_functions3.c
More file actions
executable file
·86 lines (81 loc) · 1.42 KB
/
printf_functions3.c
File metadata and controls
executable file
·86 lines (81 loc) · 1.42 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
#include "main.h"
/**
* p_unsigned - prints an integer
* @args: va_list
* Return: number of characters printed
* Code by Yemsal & Nancy
*/
int p_unsigned(va_list args)
{
char *str;
int i = 0;
unsigned int num2;
num2 = va_arg(args, int);
str = change_base(num2, 10);
i += _printarg(str);
return (i);
}
/**
* p_octal - prints an octal number.
* @args: arguments to print.
* Return: number of characters printed.
*/
int p_octal(va_list args)
{
char *str;
unsigned int num2;
int i = 0;
num2 = va_arg(args, int);
str = change_base(num2, 8);
i += _printarg(str);
return (i);
}
/**
* p_hex_upper - prints an octal number.
* @args: arguments to print.
* Return: number of characters printed.
*/
int p_hex_upper(va_list args)
{
char *str;
unsigned int num2;
int i = 0;
num2 = va_arg(args, int);
str = change_base(num2, 16);
i += _printarg(str);
return (i);
}
/**
* p_hex_low - prints an octal number.
* @args: arguments to print.
* Return: number of characters printed.
*/
int p_hex_low(va_list args)
{
char *str;
unsigned int num2;
int i = 0;
num2 = va_arg(args, int);
str = change_hex_low(num2, 16);
i += _printarg(str);
return (i);
}
/**
* p_string_esp - prints an octal number.
* @args: arguments to print.
* Return: number of characters printed.
*/
int p_string_esp(va_list args)
{
char *s;
int i = 6;
s = va_arg(args, char*);
if (s)
{
s = replace_str(s);
i = _printarg(s);
}
else
_printarg("(null)");
return (i);
}