Add all git folders
This commit is contained in:
40
C_Piscine_C_02/git/ex11/ft_putstr_non_printable.c
Normal file
40
C_Piscine_C_02/git/ex11/ft_putstr_non_printable.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putstr_non_printable.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/11 11:29:09 by gbaconni #+# #+# */
|
||||
/* Updated: 2021/08/12 11:40:23 by gbaconni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// for i in {0..127}; do printf "%02x" $i; done
|
||||
void ft_putstr_non_printable(char *str)
|
||||
{
|
||||
const char *hex = "\
|
||||
000102030405060708090a0b0c0d0e0f\
|
||||
101112131415161718191a1b1c1d1e1f\
|
||||
202122232425262728292a2b2c2d2e2f\
|
||||
303132333435363738393a3b3c3d3e3f\
|
||||
404142434445464748494a4b4c4d4e4f\
|
||||
505152535455565758595a5b5c5d5e5f\
|
||||
606162636465666768696a6b6c6d6e6f\
|
||||
707172737475767778797a7b7c7d7e7f";
|
||||
|
||||
while (*str != '\0')
|
||||
{
|
||||
if (*str >= ' ' && *str != '~' + 1)
|
||||
write(1, str, 1);
|
||||
else
|
||||
{
|
||||
write(1, "\\", 1);
|
||||
write(1, hex + *str * 2, 2);
|
||||
}
|
||||
str++;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user