E
edward_nig
Hi all,
Please I tried to copy from a text file line by line and to paste the
text in reverse order in another text file also line by line-Making the
first line the last and the last line the first.
I tried using vectors in the following codes but it just won't run.
please help
------------------------------------------
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
int main() {
vector<string> v;
ifstream in("mtext1.txt");
ofstream out("mtext2.txt");
string line;
while (getline (in, line) ) {
v.push_back(line);
}
int j = v.size();
for(int i=0; i < j; i++) {
out << v[j] ;
j=j-1;
}
}
Please I tried to copy from a text file line by line and to paste the
text in reverse order in another text file also line by line-Making the
first line the last and the last line the first.
I tried using vectors in the following codes but it just won't run.
please help
------------------------------------------
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
int main() {
vector<string> v;
ifstream in("mtext1.txt");
ofstream out("mtext2.txt");
string line;
while (getline (in, line) ) {
v.push_back(line);
}
int j = v.size();
for(int i=0; i < j; i++) {
out << v[j] ;
j=j-1;
}
}