Skip to content

Instantly share code, notes, and snippets.

@al3rez
Created April 19, 2016 11:00
Show Gist options
  • Save al3rez/9d767083716efb3ae5fab8bbdda8c738 to your computer and use it in GitHub Desktop.
Save al3rez/9d767083716efb3ae5fab8bbdda8c738 to your computer and use it in GitHub Desktop.
#include <stdio.h>
/* copy input to ouput and replace each tab by \t,
* each backspace by \b, and each backslash by \\
*/
main()
{
int c;
while ((c = getchar()) != EOF)
{
if (c == '\t')
printf("\\t");
else if (c == '\b')
printf("\\b");
else if (c == '\\')
printf("\\\\");
else
putchar(c);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment