By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 712 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

Reversing string from one text file to another new text file

P: 1
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <algorithm>
#include <fstream>
#include <ios>
#include <iterator>
#include <vector>

int main()
//for reading content from readgo.txt file
std::ifstream input_file("E:\\readgo.txt",std::ios_base::binary) ;
//for writing content to revwrite.txt file
std::ofstream output_file("E:\\revwrite.txt",std::ios_base::bina ry);

//input iterator with begining from readgo.txt
std::istreambuf_iterator<char> input_begin(input_file);
std::istreambuf_iterator<char> input_end;

//output iterator that writes to revwrite.txt
std::ostreambuf_iterator<char> output_begin(output_file);

//used for storing collection of character in vector
//Copies the elements from the readgo.txt & paste in reverse order
std::reverse_copy(input_data.begin(),input_data.en d(),output_begin);
Nov 30 '15 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.