Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstdlib>
- using namespace std;
- int main(){
- char in_file[1024], out_file[1024];
- system("clear");
- cout << "Enter the name of the input file: ";
- cin.getline(in_file, 1024, '\n');
- cout << "Enter the name of the output file: ";
- cin.getline(out_file, 1024, '\n');
- ifstream in(in_file);
- in.seekg(0, ios::end);
- long file_size = in.tellg();
- char *content = new char[file_size];
- in.seekg(0, ios::beg);
- ofstream out(out_file);
- int index = 0;
- // Reading the file and storing it in content
- while(in.get(content[index++])){}
- in.close();
- // Storing the file in reverse
- for(int i = file_size - 1; i >= 0; i--){
- out.put(content[i]);
- }
- out.close();
- delete[] content;
- return 0;
- }
Add Comment
Please, Sign In to add comment