And I am trying to read it in and do the desired outcome. When it gets to the first 'serve' there is an error. I am thinking it is because there is no number after it so when it assigns it to 'theData' it is not doing it correctly. When I print it, it looks like:
append 10
serve 10
serve 10
serve 10
serve 10
serve 10
serve 10
serve 10
serve 10
etc......
do
{
if (textFile >> theString >> theData)
{
//Stacks
if (theString == "pop")
{
cout << " Stack Pop --- Success" << endl;
}
if (theString == "push")
{
cout << " Stack Push "<< theData <<" Success" << endl;
}
if (theString == "top")
{
cout << " Stack Pop "<< theData <<" Success" << endl;
}
//Queue
if (theString == "append")
{
cout << " Queue Append "<< theData <<" Success" << endl;
cout << theString << ", " << theData << endl;
}
if (theString == "serve")
{
cout << " Queue Serve --- Success" << endl;
}
}
//else if (textFile.fail())
//{
// cout << "The file held incorrect data" << endl;
// system ("PAUSE");
// exit (1);
//}
cout << theString << ", " << theData << endl;
} while (!textFile.eof());
textFile.close();
If you could help me with this I would be super grateful. I have tried everything I can think of and I can't find anything online or in my textbook. Thanks!
Thank you for pointing that out. I thought I got everything out of it that I code but taking another look at it I saw the issue. I swear I posted that on another forum, but apparently not. Thank you cire. You saved me a lot of headache.