-
Notifications
You must be signed in to change notification settings - Fork 0
/
conversion_functions.c
90 lines (81 loc) · 1.42 KB
/
conversion_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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
#include "main.h"
/**
* handle_char_specifier - check for char
* @args: va_list object
* Return: length
*/
int handle_char_specifier(va_list args)
{
char ch;
if (args != NULL)
{
ch = va_arg(args, int);
write(1, &ch, 1);
return (1);
} /* end if */
else
{
return (-1);
} /* end else */
} /* End function */
/**
* handle_string_specifier - check for string
* @args: va_list object
* Return: length
*/
int handle_string_specifier(va_list args)
{
char *mystring;
int len;
if (args != NULL)
{
mystring = va_arg(args, char *);
len = _strlen(mystring);
write(1, mystring, len);
return (len);
} /* end if */
else
{
return (-1);
} /* end else */
} /* End function */
/**
* handle_percent_specifier - check for percent
*
* Return: length
*/
int handle_percent_specifier(void)
{
char percent = '%';
write(1, &percent, 1);
return (1);
} /* end function */
/**
* handle_decimal_specifier - check for decimal
* @args: va_list object
* Return: length
*/
int handle_decimal_specifier(va_list args)
{
int myint;
int len;
myint = va_arg(args, int);
len = _itoa(myint);
return (len);
} /* end function */
/**
* handle_integer_specifier - check for integer
* @args: va_list object
* Return: length
*/
int handle_integer_specifier(va_list args)
{
int myint;
int len;
myint = va_arg(args, int);
len = _itoa(myint);
return (len);
} /* end function */