-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainReplay.cpp
More file actions
57 lines (51 loc) · 974 Bytes
/
mainReplay.cpp
File metadata and controls
57 lines (51 loc) · 974 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//Diana Plosnita 2018526
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
if(argc < 2)
{
cout << "File name or action not provided, execute again" << endl;
return 1;
}
string action = argv[1];
string input_name = argv[2];
if(action == "v")
{
ifstream input_file;
input_file.open(input_name);
if (!input_file)
{
cout << "Error in reading file" << "\n";
return 1;
}
string line;
while ( getline (input_file, line) )
{
cout << line << '\n';
}
input_file.close();
}
else if(action == "f")
{
string output_name = argv[3];
ifstream input_file;
ofstream output_file;
input_file.open(input_name);
if (!input_file)
{
cout << "Error in reading file" << "\n";
return 1;
}
output_file.open(output_name);
string line;
while ( getline (input_file, line) )
{
output_file << line << '\n';
}
input_file.close();
output_file.close();
}
}