Hi,
I have to make a program that takes an input text file and reverses the contents of that file, and outputs that into another text file. I am new to stacks, but what I have so far nothing happens, it just outputs a blank text file. I just wanted to check what is missing here.
Thanks.
#include <iostream>
#include <fstream>
#include <stack>
#include <string>
using namespace std;
int main() {
stack<string> myStack;
string character;
ifstream infile;
ofstream outfile;
infile.open("TextIn.txt");
outfile.open("TextOut.txt");
while (infile)
{
myStack.push(character);
}
while (!myStack.empty())
{
outfile << myStack.top() << endl;
myStack.pop();
}
infile.close();
outfile.close();
return 0;
}