[TUHS] Literal character escapes in v7

Will Senn will.senn at gmail.com
Tue Nov 7 14:21:12 AEST 2017


I wrote a snippet from my K&R C studies to convert tabs and backspaces 
to \t \b to display them, the code looks like this:

/* ex 1-8 */

main()
{
     int c, sf;

     while((c = getchar()) != EOF) {
         if(c == '\t')
             printf("\\t");
          if(c == '\b')
             printf("\\b");
         else
             putchar(c);
     }
}

I'm not looking for code review, but the code is intended to replace the 
tabs and backspaces with \t and \b respectively, but I haven't been able 
to test it because I can't seem to make a backspace character appear in 
input. In later unices, ^V followed by the backspace would work, but 
that's not part of v7. Backspace itself is my erase character, so 
anytime I just type it, it backspaces :).

Thanks,

Will

-- 
GPG Fingerprint: 68F4 B3BD 1730 555A 4462  7D45 3EAA 5B6D A982 BAAF




More information about the TUHS mailing list