32 lines
805 B
C
32 lines
805 B
C
int getchar();
|
|
int putchar(int ch);
|
|
int printf(char* format, ...);
|
|
|
|
int main() {
|
|
int ch;
|
|
while ((ch = getchar()) != -1) {
|
|
if (ch == '\\') {
|
|
ch = getchar();
|
|
if (ch == 'n') {
|
|
ch = '\n';
|
|
} else if (ch == 't') {
|
|
ch = '\t';
|
|
} else if (ch == 'r') {
|
|
ch = '\r';
|
|
} else if (ch == '0') {
|
|
ch = '\0';
|
|
} else if (ch == '\\') {
|
|
ch = '\\';
|
|
} else if (ch == '\'') {
|
|
ch = '\'';
|
|
} else if (ch == '\"') {
|
|
ch = '\"';
|
|
} else {
|
|
printf("unexpected escaped character: '\\%c'\n", ch);
|
|
return 1;
|
|
}
|
|
}
|
|
putchar(ch);
|
|
}
|
|
return 0;
|
|
} |