34 lines
499 B
C
34 lines
499 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
/*A really silly way to complete exercise 1-10 of KNR C*/
|
|
|
|
int main(){
|
|
|
|
int a = getchar();
|
|
|
|
if (a == EOF){ /*Check whether first character is EOF*/
|
|
printf ("No data to parse.");
|
|
EXIT_FAILURE;
|
|
}
|
|
|
|
loop_start:
|
|
if (a == '\t' || a == '\b' || a == '\\'){
|
|
if (a == '\t')
|
|
printf("\\t");
|
|
if (a == '\b')
|
|
printf("\\b");
|
|
if (a == '\\')
|
|
printf ("\\\\");
|
|
} else {
|
|
putchar(a);
|
|
}
|
|
|
|
a = getchar();
|
|
|
|
if (a != EOF)
|
|
goto loop_start;
|
|
|
|
|
|
return 0;
|
|
}
|