-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.c
45 lines (38 loc) · 1009 Bytes
/
main.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
/*
* Divide the entire input file into different groups based on the available memory
* resource restrictions.
*
* Read each group of the input file into the memory buffer, sort the records in the memory buffer,
* save the sorted records in a temporary sub file. This process is called one run.
*
* At the end of this sort phase, # temporary sorted sub files will be created.
* */
/*
* main.c
*
* Created on: Nov 23, 2022
* Author: Chris Bao
*
* */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "external_sort.h"
#include "external_merge.h"
int main() {
FILE *fp;
char filename[100];
// make sure the input file exist
if ((fp = fopen("input.txt", "r")) == NULL) {
fprintf(stderr, "Can't open input file. Please run randomNumber.sh script first.\n ");
return 1;
}
// sort phase
separationSort(fp);
fclose(fp);
// merge phase
exMergeSort();
printf("Success\n");
return 0;
}