I'm learning c from K&R's book, and I wanted to work on this task:
My code, which is here:
#include <stdio.h>
int main()
{
int c;
while ((c = getchar()) != EOF) {
if (c == '\t') {
putchar('\\');
putchar('t');
}
else if (c == '\b') {
putchar('\\');
putchar('b');
}
else if (c == '\\') {
putchar('\\');
putchar('\\');
}
else
putchar(c);
}
}
works just fine with slashes and tabs, but I don't know how to check if my code works with a real backspace character in text (If it's even possible?).
I used this input:
there will be now an tab: .
in additon, here are three slashes: \,\,\.
and checked the output in this site, and it worked just fine, I got this output:
there will be now an tab: \t.
in additon, here are three slashes: \\,\\,\\.