On Monday, 10 May 2021 12:14:10 CEST Sven Eckelmann wrote: > void sanitize_string(const char *str) > { > while (*str) { > if (*str == '"') > puts("\""); > else if (*str == '\\') > puts("\\\\"); > else if (!isprint(*str)) > printf("\\x%02x", *str); > else > putc(*str); > > str++; > } > } Should have tested this. It should be more like: void sanitize_string(const char *str) { while (*str) { if (*str == '"' || *str == '\\') { putchar('\\'); putchar(*str); } else if (!isprint(*str)) { printf("\\x%02x", *str); } else { putchar(*str); } } } Kind regards, Sven