-
Notifications
You must be signed in to change notification settings - Fork 0
/
echo1.c
82 lines (77 loc) · 2.46 KB
/
echo1.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
int i;
argc--;
int j = 0;
int lenght;
int t;
int p;
int flag = 0;
if (!strcmp(argv[1],"-n") || !strcmp(argv[1],"-E") || !strcmp(argv[1],"-e")) {
if (!strcmp(argv[1],"-e")) {
/* 澧墾 鷗 麒侊이 */
p = 0;
t = 0;
for (i = 2; i <= argc; i++) {
lenght = strlen(argv[i]);
j = 0;
/* 澧墾 鷗 騎兼珖이 */
while (j < lenght) {
if (argv[i][j] == '\\') {
j++;
/* 麒當읠 \n */
if (argv[i][j] == 'n') {
for (t = p; t < j-1; t++) {
printf("%c", argv[i][t]);
}
printf("\n");
}
if (argv[i][j] == 't') {
for (t = p; t < j-1; t++)
printf("%c", argv[i][t]);
printf("%s"," ");
printf("%s"," ");
printf("%s"," ");
printf("%s"," ");
}
if (argv[i][j] == 'r') {
p = p + j;
t = j-1;
}
p = j+1;
j++;
}
j++;
}
for (p = t+2; p < lenght; p++)
printf("%c", argv[i][p]);
}
printf("\n");
}
if (!strcmp(argv[1],"-n")) {
for (i = 2; i <= argc; i++) {
if (i == argc)
printf("%s", argv[i]);
else
printf("%s ",argv[i]);
}
}
if (!strcmp(argv[1],"-E")) {
for (i = 2; i <= argc; i++) {
if (i == argc)
printf("%s\n", argv[i]);
else
printf("%s ",argv[i]);
}
}
}
else {
for (i = 1; i <= argc; i++) {
if (i == argc)
printf("%s\n", argv[i]);
else
printf("%s ",argv[i]);
}
}
}