2025-08-14 17:27:43 +00:00
# include <stdio.h>
int main ( ) {
2025-08-14 17:42:15 +00:00
int a = 0 ; /*Initializing a as zero; this doesn't matter because getchar is called at the top of the loop */
2025-08-14 17:27:43 +00:00
while ( a ! = EOF ) {
a = getchar ( ) ;
2025-08-14 17:42:15 +00:00
if ( a = = ' \b ' | | a = = ' \t ' | | a = = ' \\ ' ) { /*Test whether the currently selected character is a tab, backspace, or backslash */
2025-08-14 17:27:43 +00:00
if ( a = = ' \b ' ) {
printf ( " \\ b " ) ;
continue ;
}
if ( a = = ' \t ' ) {
printf ( " \\ t " ) ;
continue ;
2025-08-14 17:42:15 +00:00
} else { /*There are only three possible cases here, and by the time we get here, we've tested two, hence an else statement is more efficient than doing another entire if statement*/
2025-08-14 17:29:11 +00:00
printf ( " \\ \\ " ) ;
2025-08-14 17:27:43 +00:00
continue ;
}
} else {
putchar ( a ) ;
}
}
return 0 ;
}