-
Notifications
You must be signed in to change notification settings - Fork 46
/
echo.c
48 lines (41 loc) · 888 Bytes
/
echo.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
#include <fcntl.h>
static char buffer[512];
int main(int argc, char *argv[]){
char *p, *dest;
char c;
int i = 1;
if(argc < 2)
return 1;
dest = buffer;
while (i < argc){
p = argv[i];
if (i > 1)
*dest++ = ' ';
while(*p){
c = *p;
if(c == '\\'){
c = *++p;
switch (c)
{
case 'n':
c = '\n';
break;
case 't':
c = '\t';
break;
default:
break;
}
}
*dest++ = c;
p++;
}
*dest = '\0';
i++;
}
*dest++ = '\n';
*dest++ = '\0';
printf("%s", buffer);
return 0;
}