-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy path2.c
More file actions
38 lines (35 loc) · 742 Bytes
/
Copy path2.c
File metadata and controls
38 lines (35 loc) · 742 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
#include <stdio.h>
int main()
{
FILE *fp1, *fp2, *fp3;
int num1, num2;
fp1 = fopen("DATA1", "r");
fp2 = fopen("DATA2", "r");
fp3 = fopen("DATA", "w");
fscanf(fp1, "%d", &num1);
fscanf(fp2, "%d", &num2);
while (!feof(fp1) && !feof(fp2))
{
if (num1 < num2)
{
fprintf(fp3, "%d\n", num1);
fscanf(fp1, "%d", &num1);
}
else
{
fprintf(fp3, "%d\n", num2);
fscanf(fp2, "%d", &num2);
}
}
while (!feof(fp1))
{
fprintf(fp3, "%d\n", num1);
fscanf(fp1, "%d", &num1);
}
while (!feof(fp2))
{
fprintf(fp3, "%d\n", num2);
fscanf(fp2, "%d", &num2);
}
return 0;
}