#include <stdio.h>
#include <unistd.h>
void ft_putstr_non_printable(char *str)

{

    int i = 0;


    while (str[i]!= '\0')

    {

        if (str[i] >= 32 && str[i] <= 126) // printable characters

        {

            write(1, &str[i], 1);

        }

        else

        {
            
            write(1, "\\", 1);
            char one = "0123456789abcdef"[str[i] / 16];
            char two = "0123456789abcdef"[str[i] % 16];
            write(1, &one, 1);
           write(1, &two, 1);

        }

        i++;

    }

}
int main() {
    char *str = "Coucou\ntu vas bien ?";

    printf("%s,\n", "Coucoutu vas bien ?");

    ft_putstr_non_printable(str);
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: