-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
46 lines (30 loc) · 839 Bytes
/
main.cpp
File metadata and controls
46 lines (30 loc) · 839 Bytes
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
#include<iostream>
#include<fstream>
#include<sstream>
#include "json_formatter.cpp"
using namespace std;
int main(int argc, char *argv[]) {
if (argc != 3) {
cerr << "Please provide input and output file paths!" << endl;
return 1;
}
string input_filename = argv[1];
string output_filename = argv[2];
ifstream input_file(input_filename);
if (!input_file) {
std::cerr << "File could not be opened!" << std::endl;
return 1;
}
stringstream buffer;
buffer << input_file.rdbuf();
string input = buffer.str();
string res = JsonFormatter::format(input);
ofstream file(output_filename);
if (!file) {
cerr << "File could not be opened!" << endl;
return 1;
}
file << res;
file.close();
return 0;
}