-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
44 lines (36 loc) · 1.06 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
36
37
38
39
40
41
42
43
44
#include "randomFile.hpp"
void writeFile(RandomFile& randomFile, int n) {
Record record {};
for (int i = 0; i < n; i++) {
record.setData();
try {
randomFile.write(record);
}
catch (std::exception& e) {
std::cout << std::endl << e.what();
}
std::cout << std::endl;
}
}
[[maybe_unused]] void readFile(RandomFile& randomFile) {
std::cout << "-------- show index --- \n";
randomFile.showIndex();
std::cout << "-------- show data --- \n";
randomFile.scanAll();
std::cout << "-------- show sorted data --- \n";
randomFile.scanAllByIndex();
std::cout << "\n";
}
void searchRecord(RandomFile& randomFile) {
std::string search;
std::cout << "Key to be searched: ";
std::cin >> search;
Record record = randomFile.search(search);
std::cout << "Record information: " << record.toString() << std::endl;
}
int main() {
RandomFile randomFile("data.dat", "index.dat");
writeFile(randomFile, 4);
searchRecord(randomFile);
return EXIT_SUCCESS;
}