Exercise #1.10 - Copy Input to Output

alendr · updated September 15, 2021 · C
#include <stdio.h>
/* replace tabs, backslashes and 
backspaces - with visible characters */ 
int main() {
    int c; 
    
    while ((c = getchar()) != EOF) { 
        if (c == '\t')
            printf("\\t"); 
        if (c == '\b')
            printf("\\b"); 
        if (c == '\\') 
            printf("\\\\"); 
        if (c != '\b') 
            if (c != '\t')
                if (c != '\\') 
                    putchar(c); 
                                    }
}

Comments

Please sign up or log in to contribute to the discussion.