-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2_specifier_func.c
More file actions
64 lines (56 loc) · 1.25 KB
/
Copy path2_specifier_func.c
File metadata and controls
64 lines (56 loc) · 1.25 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
#include "main.h"
/**
* print_unsigned_octal - Prints an unsigned integer in octal format
*
* @ap: A va_list containing the integer to print
* @count: A pointer to a counter of printed characters
*/
void print_unsigned_octal(va_list ap, int *count)
{
unsigned int num;
char octal[100];
int i, length;
num = va_arg(ap, unsigned int);
if (num == 0)
{
*count += _putchar('0');
return;
}
for (i = 0; num != 0; i++)
{
octal[i] = (num % 8) + '0';
num /= 8;
}
length = i;
for (i = length - 1; i >= 0; i--)
*count += _putchar(octal[i]);
}
/**
* print_binary - Display binary number to stdout
*
* @ap: A va_list containing the unsigned integer value
* @count: Pointer to a counter of printed characters
*/
void print_binary(va_list ap, int *count)
{
unsigned int num = va_arg(ap, unsigned int);
decimal_to_binary(num, count);
}
/**
* print_nonprintable - print hexadecimal characters of non printable values
*
* @ap: variable name of va list
* @count: Pointer to a counter of printed characters
*/
void print_nonprintable(va_list ap, int *count)
{
unsigned int c = va_arg(ap, int);
if (c < 32 || c > 127)
{
*count += _putchar('\\');
*count += _putchar('x');
if (c < 16)
*count += _putchar('0');
decimal_to_HEX(c, count);
}
}