-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathfile_handling.cpp
More file actions
33 lines (29 loc) · 886 Bytes
/
file_handling.cpp
File metadata and controls
33 lines (29 loc) · 886 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
//============================================================================
// Name : file_handling.cpp
// Author : Ak0s
// Description : Exam 3
//============================================================================
#include "file_handling.hpp"
void FileHandling::read_from_file(std::string filename) {
std::ifstream source;
source.open(filename);
if (source.is_open()) {
std::string lines;
while (getline(source, lines)) {
input_from_file += lines + '\n';
}
source.close();
}
else {
std::cerr << "Could open" << filename << "!" << std::endl;
}
}
void FileHandling::write_to_file(std::string filename, std::string content) {
std::ofstream file_to_write;
file_to_write.open(filename);
file_to_write << content;
file_to_write.close();
}
std::string FileHandling::get_input_from_file() {
return input_from_file;
}