-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff.c
More file actions
48 lines (39 loc) · 1.08 KB
/
Copy pathdiff.c
File metadata and controls
48 lines (39 loc) · 1.08 KB
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
#include <stdio.h>
#include <string.h>
#define MAX_LINE_LENGTH 1024
int main(void) {
FILE *first = fopen("1.txt", "r");
FILE *second = fopen("2.txt", "r");
char buffer1[MAX_LINE_LENGTH];
char buffer2[MAX_LINE_LENGTH];
while (!feof(first) && !feof(second)) {
if (fgets(buffer1, MAX_LINE_LENGTH, first) == NULL) {
break;
}
if (fgets(buffer2, MAX_LINE_LENGTH, second) == NULL) {
break;
}
buffer1[strcspn(buffer1, "\n")] = '\0';
buffer2[strcspn(buffer2, "\n")] = '\0';
if (strcmp(buffer1, buffer2) != 0) {
printf("1> %s\n", buffer1);
printf("2> %s\n", buffer2);
puts("--");
}
}
while (!feof(first)) {
if (fgets(buffer1, MAX_LINE_LENGTH, first) == NULL) {
break;
}
printf("1> %s", buffer1);
}
while (!feof(second)) {
if (fgets(buffer2, MAX_LINE_LENGTH, second) == NULL) {
break;
}
printf("2> %s", buffer2);
}
fclose(first);
fclose(second);
return 0;
}