Add all git folders
This commit is contained in:
59
C_Piscine_C_02/git_old/ex11/ft_putstr_non_printable.c
Normal file
59
C_Piscine_C_02/git_old/ex11/ft_putstr_non_printable.c
Normal file
@@ -0,0 +1,59 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putstr_non_printable.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/11 11:29:09 by gbaconni #+# #+# */
|
||||
/* Updated: 2021/08/11 16:56:40 by gbaconni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// for i in {0..255}; do printf "%02x" $i; done
|
||||
void ft_putstr_non_printable(char *str)
|
||||
{
|
||||
int size;
|
||||
const char *hex = "000102030405060708090a\
|
||||
0b0c0d0e0f101112131415\
|
||||
161718191a1b1c1d1e1f20\
|
||||
2122232425262728292a2b\
|
||||
2c2d2e2f30313233343536\
|
||||
3738393a3b3c3d3e3f4041\
|
||||
42434445464748494a4b4c\
|
||||
4d4e4f5051525354555657\
|
||||
58595a5b5c5d5e5f606162\
|
||||
636465666768696a6b6c6d\
|
||||
6e6f707172737475767778\
|
||||
797a7b7c7d7e7f80818283\
|
||||
8485868788898a8b8c8d8e\
|
||||
8f90919293949596979899\
|
||||
9a9b9c9d9e9fa0a1a2a3a4\
|
||||
a5a6a7a8a9aaabacadaeaf\
|
||||
b0b1b2b3b4b5b6b7b8b9ba\
|
||||
bbbcbdbebfc0c1c2c3c4c5\
|
||||
c6c7c8c9cacbcccdcecfd0\
|
||||
d1d2d3d4d5d6d7d8d9dadb\
|
||||
dcdddedfe0e1e2e3e4e5e6\
|
||||
e7e8e9eaebecedeeeff0f1\
|
||||
f2f3f4f5f6f7f8f9fafbfc\
|
||||
fdfeff";
|
||||
|
||||
size = 0;
|
||||
while (str[size++] != '\0')
|
||||
continue ;
|
||||
while (--size)
|
||||
{
|
||||
if (*str >= ' ' && *str <= '~')
|
||||
write(1, str, 1);
|
||||
else
|
||||
{
|
||||
write(1, "\\", 1);
|
||||
write(1, hex + *str * 2, 2);
|
||||
}
|
||||
str++;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user