#include <stdio.h>

void ft_putstr_non_printable(char *str) {
    while (*str) {
        if (*str >= 32 && *str <= 126) {
            putchar(*str);
        } else {
            printf("\\x%02x", *str);
        }
        str++;
    }
}

int main() {
    char *str = "Coucou\ntu vas bien ?";
    printf("%s\n", str);
    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: