What is happening here?
void palindromemgr(ifstream& in, ofstream& out, Stack& S)
{
string c; //candidate
while (true)
{
cout << "entering first loop" << endl; //debugging line
if (in.eof()) break;
in >> c;
cout << "this is the value in c :" << c << endl; //debugging line
for (int a = 0;a < c.length();a++)
{
cout << "entering for loop" << endl; //debugging line
S.Push(c[a]);
}
while (true)
{
cout << "entering second loop" << endl; //debugging line
if (S.IsEmpty()) break;
cout << S.Pop();
}
cout << endl;
}
}
I expected this to read up to the first white space encountered in the input file, store that into the string c, grab each character in the string and push it into my stack (S), then output the contents of the stack, the loop through the rest of the input file the same way. Instead this is what I get.
entering first loop
this is the value in c :
entering second loop
entering first loop
AND it is deleting the contents of my input file!!!