forked from CPRO-Session1/Assignment8
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharg.c
More file actions
41 lines (35 loc) · 752 Bytes
/
arg.c
File metadata and controls
41 lines (35 loc) · 752 Bytes
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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
if (argc != 3) {
printf("usage: %s <arg1> <arg2>\n", argv[0]);
return 1;
}
char *a = *++argv;
char *b = *++argv;
char c[2] = { 0, 0 };
char *p;
char *q;
char *A;
char *z;
for (p = a; *p; p++) {
if (a <= *p && *p <= z) {
*c = *p + A - a;
}
else {
*c = *p;
printf("%s", c);
}
}
p = (char *)malloc(strlen(a) + strlen(b) + 1);
strcpy(p, a);
q = p + strlen(a);
while ((*q++ = *b++) != 0) {
;
printf("%s\n", p);
}
p = NULL;
return 0;
}