-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
44 lines (34 loc) · 853 Bytes
/
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 "main.h"
#include "processData.h"
using namespace std;
void usage();
int main(int argc, char** argv) {
ifstream inFile;
ofstream outFile;
if (argc != 3){
usage();
return EXIT_FAILURE;
}
inFile.open(argv[1]);
if (!inFile) {
cout << "Unable to open file " << argv[1];
return EXIT_FAILURE; // terminate with error
}
outFile.open(argv[2]);
if (!outFile) {
cout << "Unable to open file " << argv[2];
return EXIT_FAILURE; // terminate with error
}
ProcessData * data = new ProcessData();
string line;
while (getline(inFile, line)) {
outFile << data->process(line) << endl;
}
inFile.close();
outFile.close();
delete data;
return EXIT_SUCCESS;
}
void usage() {
cout << "Usage: main <input file> <output file>" << endl;
}