// SPDX-FileCopyrightText: 2024 Tomasz Kramkowski // SPDX-LicenseIdentifier: GPL-3.0-or-later // A tool to produce escaped C strings. // Only escapes tabs, newlines, double quotes and backslashes. #include int main(void) { int c; while (c = getchar(), c != EOF) { switch (c) { case '\t': fputs("\\t", stdout); break; case '\n': fputs("\\n", stdout); break; case '"': fputs("\\\"", stdout); break; case '\\': fputs("\\\\", stdout); break; default: putchar(c); break; } } }