-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_putstr_non_printable.c
More file actions
44 lines (40 loc) · 1.4 KB
/
ft_putstr_non_printable.c
File metadata and controls
44 lines (40 loc) · 1.4 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr_non_printable.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: knzeng-e <knzeng-e@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/03/26 11:26:53 by knzeng-e #+# #+# */
/* Updated: 2016/03/26 11:59:46 by knzeng-e ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static void ft_print_hexa(char non_printable)
{
char *hexa;
hexa = "0123456789abcdef";
if ((unsigned int)non_printable > 16)
{
ft_print_hexa(non_printable / 10);
ft_print_hexa(non_printable % 10);
}
else
ft_putchar(hexa[(unsigned int)non_printable]);
}
void ft_putstr_non_printable(char *str)
{
while (*str)
{
if ((*str < 32 && *str >= 0) || *str == 127)
{
ft_putchar('\\');
if ((unsigned int)(*str) < 16)
ft_putchar('0');
ft_print_hexa(*str);
}
else
ft_putchar(*str);
str++;
}
}