-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
41 lines (33 loc) · 710 Bytes
/
main.cpp
File metadata and controls
41 lines (33 loc) · 710 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
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
using namespace std;
void readfromfile(vector<string>& lines) {
ifstream in("file1.txt");
string line;
while (getline(in, line)){
lines.push_back(line);
}
in.close();
}
void printlines(const vector<string>& lines) {
for (const auto& line:lines) {
cout << line << endl;
}
}
void writetowile(const vector<string>& lines) {
ofstream out;
out.open("file2.txt");
for (const auto& line : lines){
out << line << endl;
}
out.close();
}
int main() {
vector<string> lines;
readfromfile(lines);
printlines(lines);
writetowile(lines);
return 0;
}