I need to reverse the order of the file and outputted into another file. For example, the
input:
hello
this is a testing file again
just so much fun
Expected output:
just so much fun
this is a testing file again
hello
This is my current code, it printed to where it reverses the order of the lines but also the order of the characters of each word.
Current:
nuf hcum os tsuj
niaga elif gnitset a si siht
olleh
int print_rev(string filename, char c){
ifstream inStream (filename);
ofstream outStream;
inStream.seekg(0,inStream.end);
int size = inStream.tellg();
outStream.open("output.txt");
for (int j=1; j<=size; j++){
inStream.seekg(-j, ios::end);
c=inStream.get();
outStream << c;
}
inStream.close();
outStream.close();
return 0;
}