-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
85 lines (51 loc) · 1.92 KB
/
main.cpp
File metadata and controls
85 lines (51 loc) · 1.92 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include "ArgumentManager.h"
#include <vector>
using namespace std;
//create function to check for duplicate
struct Books {
string genre;
string title;
string author;
string year;
};
int main (int argc, char* argv[]) {
ArgumentManager am (argc, argv);
string input = am.get("input");
string output = am.get("output");
string command = am.get("command");
ifstream in("input12.txt"); // input file stream - reading from file
ifstream com("command12.txt"); // reading from the command txt file
ofstream out("answer.txt"); //output file stream
const int MAX_BOOKS = 10000; // create dynamic array and sort
int count = 0;
string temp;
//const char* myArray;
//myArray = new char[MAX_BOOKS];
//string *data = new string [MAX_BOOKS];
Books* p_studentData = new Books[MAX_BOOKS];
in.open(input);
if(!in.is_open()) {
// cout<<"Could not read " <<endl;
return -1;
}
while (!in.eof()) {
string genre ="", genretitle = "", title = "" , titletile = "" , author ="", authortitle ="" , year = "" , yeartitle ="";
getline(in,genre,':');
getline(in, genretitle,',');
getline(in,title,':');
getline(in,titletile,',');
getline(in, author, ':');
getline(in,authortitle,',');
getline(in,year,':');
getline(in,yeartitle,'}');
for(int i =0;i <MAX_BOOKS;i++) {
cout << p_studentData[MAX_BOOKS].genre <<p_studentData[MAX_BOOKS].author<<p_studentData[MAX_BOOKS].title<<p_studentData[MAX_BOOKS].year<<endl;
}
}
delete[] p_studentData;
return 0;
}