23 lines
		
	
	
		
			619 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			619 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #include <fstream>
 | |
| #include <iostream>
 | |
| using namespace std;
 | |
| 
 | |
| string getFileContent(const string& file)
 | |
| {
 | |
|     ifstream fileStream;
 | |
|     string lineinput, fullinput;
 | |
|     fileStream.open(file, ios::in);
 | |
|     if (fileStream.is_open()) while (getline(fileStream, lineinput)) {
 | |
|         fullinput.append(lineinput + "\n");
 | |
|     } else {
 | |
|         cout << "Could not open \"" << file << "\"." << endl;
 | |
|         exit(EXIT_FAILURE);
 | |
|     }
 | |
|     fileStream.close();
 | |
|     return fullinput;
 | |
| }
 | |
| 
 | |
| void outputFileContent(const string& file, const string_view content) {
 | |
|     ofstream outputFile (file, ofstream::out);
 | |
|     outputFile << content;
 | |
| } |