-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathS.c
More file actions
37 lines (36 loc) · 667 Bytes
/
S.c
File metadata and controls
37 lines (36 loc) · 667 Bytes
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
#include "holberton.h"
/**
*print_S - prints /x then special char val in hex
*@count: keeps count
*@list: va_list
*Return: count
*/
int print_S(int count, va_list list)
{
char *temp_string = va_arg(list, char *);
int x = 0;
unsigned int num = 0;
if (!temp_string)
{
count += _printf("(null)");
return (count);
}
while (temp_string && temp_string[x])
{
if ((temp_string[x] > 0 && temp_string[x] < 32) ||
temp_string[x] >= 127)
{
_putchar('\\');
count++;
_putchar('x');
count++;
num = (unsigned int) temp_string[x];
count = print_SX(count, num);
x++;
}
_putchar(temp_string[x]);
x++;
count++;
}
return (count);
}