\t
, each backspace by \b
, and each backslash by \\
.
This makes tabs and backspaces visible in an unambiguous way.
/* Gregory Pietsch <gkp1@flash.net> */
/*
* Here's my attempt at a Category 0 version of 1-10.
*
* Gregory Pietsch
*/
#include <stdio.h>
int main()
{
int c, d;
while ( (c=getchar()) != EOF) {
d = 0;
if (c == '\\') {
putchar('\\');
putchar('\\');
d = 1;
}
if (c == '\t') {
putchar('\\');
putchar('t');
d = 1;
}
if (c == '\b') {
putchar('\\');
putchar('b');
d = 1;
}
if (d == 0)
putchar(c);
}
return 0;
}
#include <stdio.h>
#define ESC_CHAR '\\'
int main(void)
{
int c;
while((c = getchar()) != EOF)
{
switch(c)
{
case '\b':
/* The OS on which I tested this (NT) intercepts \b characters. */
putchar(ESC_CHAR);
putchar('b');
break;
case '\t':
putchar(ESC_CHAR);
putchar('t');
break;
case ESC_CHAR:
putchar(ESC_CHAR);
putchar(ESC_CHAR);
break;
default:
putchar(c);
break;
}
}
return 0;
}