-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrprintfunc2.c
57 lines (50 loc) · 916 Bytes
/
errprintfunc2.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
#include "shell.h"
/**
* eprint_percent - prints a percent to the STDERR
* @char_count: number of characters printed
*
* Return: 1
*/
int eprint_percent(int *char_count)
{
eprint_char(char_count, '%');
return (1);
}
/**
* handle_format - handle format for commands
* @p: Input
* @args: List to va_arg argument
* @char_count: Pointer to number of characters printed
*/
void handle_format(const char *p, va_list args, int *char_count)
{
for (; *p != '\0'; p++)
{
if (*p != '%')
{
eprint_char(char_count, *p);
continue;
}
p++;
switch (*p)
{
case 'c':
eprint_char(char_count,
(char)va_arg(args, int));
break;
case 's':
eprint_str(va_arg(args, char *));
break;
case 'i':
case 'd':
eprint_int(va_arg(args, int));
break;
case '%':
eprint_percent(char_count);
break;
default:
eprint_char(char_count, *p);
break;
}
}
}