-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
37 lines (24 loc) · 1.01 KB
/
main.cpp
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
#include <stdio.h>
#include <assert.h>
#include <cstddef>
#include "functions.h"
#include "../MyFunctions/QsortFunc.h"
int main(int argc, const char *argv[])
{
char* outputFile = "HamletOutput.txt";
InputFile inputFile = {"HamletOrig.txt"};
checkArg(argc, argv, &inputFile, &outputFile);
// fileInput
FILE* openedFile = fopen(inputFile.fileName, "r");
Status status = (Status) readFileToLinesStruct(openedFile, &inputFile);
qsort(inputFile.arrayOfLines, inputFile.numberOfLines, sizeof(Line), cmpstruct);
FILE* fileOut = fopen(outputFile, "w");
status = (Status) printArrayInFile(fileOut, &inputFile);
fprintf(fileOut, "-------------------------------------------\n");
Qsort(inputFile.arrayOfLines, inputFile.numberOfLines, sizeof(Line), cmpstructReverse);
status = (Status) printArrayInFile(fileOut, &inputFile);
fprintf(fileOut, "-------------------------------------------\n");
printOrig(fileOut, inputFile.text);
fclose(fileOut);
return status;
}