-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprinters.c
More file actions
92 lines (82 loc) · 1.27 KB
/
printers.c
File metadata and controls
92 lines (82 loc) · 1.27 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
#include "main.h"
#include <stdlib.h>
#include <stdio.h>
/**
* _print_a_char - Prints a char
* @args: A list of variadic arguments
*
* Return: The length of the character
*/
int _print_a_char(va_list args)
{
_write(va_arg(args, int));
return (1);
}
/**
* _print_a_string - Prints a string
* @args: A list of variadic arguments
*
* Return: The length of the string
*/
int _print_a_string(va_list args)
{
char *arg = va_arg(args, char *);
int i = 0;
if (arg != NULL)
{
while (arg[i])
{
_write(arg[i]);
i++;
}
return (i);
}
_write('(');
_write('n');
_write('u');
_write('l');
_write('l');
_write(')');
return (6);
}
/**
* _print_a_integer - Prints a integer
* @args: A list of variadic arguments
*
* Return: The length of the string
*/
int _print_a_integer(va_list args)
{
int count = 1, m = 0;
unsigned int n = 0;
n = va_arg(args, int);
m = n;
if (m < 0)
{
_write('-');
m = m * -1;
n = m;
count += 1;
}
while (n > 9)
{
n = n / 10;
count++;
}
_recursion_integer(m);
return (count);
}
/**
* _recursion_integer - Prints a integer
* @a: integer to print
*
* Return: Nothing
*/
void _recursion_integer(int a)
{
unsigned int t;
t = a;
if (t / 10)
_recursion_integer(t / 10);
_write(t % 10 + '0');
}