-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram8.c
52 lines (46 loc) · 1.35 KB
/
program8.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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main() {
FILE *fp;
int i, addrl, l, j, staddrl;
char name[10], line[50], namel[10], addr[10], rec[10], ch, staddr[10];
printf("Enter program name: ");
scanf("%s", name);
fp = fopen("abssrc.txt", "r");
if (fp == NULL) {
printf("Error opening file.\n");
return 1;
}
fscanf(fp, "%s", line);
for (i = 2, j = 0; (i < 8) && (j < 6); i++, j++) {
namel[j] = line[i];
}
namel[j] = '\0';
printf("Name from obj: %s\n", namel);
if (strcmp(name, namel) == 0) {
do {
fscanf(fp, "%s", line);
if (line[0] == 'T') {
for (i = 2, j = 0; (i < 8) && (j < 6); i++, j++) {
staddr[j] = line[i];
}
staddr[j] = '\0';
staddrl = atoi(staddr);
i = 12;
while (line[i] != '$') {
if (line[i] != '^') {
printf("00%d\t%c%c\n", staddrl, line[i], line[i + 1]);
staddrl++;
i = i + 2;
} else {
i++;
}
}
} else if (line[0] == 'E') {
fclose(fp);
}
} while (!feof(fp));
}
return 0;
}