Question: Write a program that opens a text file, and displays the contents and stores the contents into a stack of characters. The program will then
Write a program that opens a text file, and displays the contents and stores the contents into a stack of characters. The program will then pop the characters from the stack, and save them in a second file in reverse order, then open the second file and read and display the contents.

header file
#ifndef STACKOFCHARS_H_INCLUDED #define STACKOFCHARS_H_INCLUDED
using namepsace std;
template
class DynStack { private: struct StackNode { T value; StackNode *next; };
StackNode *top;
public: DynStack() { top = nullptr; } void push(T); void pop(T &); bool isEmpty(); };
//*********************************************************** //* Member function push pushes the argument onto the stack.* //***********************************************************
template
void DynStack
if (isEmpty()) { top = newNode; newNode->next = nullptr; }
else // Otherwise, insert NewNode before top { newNode->next = top; top = newNode; } }
//********************************************************* // Member function pop pops the value at the top of the stack off, * // and copies it into the variable passed as an argument. * //*********************************************************
template
void DynStack
if (isEmpty()) { cout
else // pop value off top of stack { num = top->value; temp = top->next; delete top; top = temp; } }
//********************************************************* // Member funciton isEmpty returns true if the stack * * // is empty, or false otherwise. * * //*********************************************************
template
bool DynStack
if (!top) { status = true; }
return status; }
#endif // STACKOFCHARS_H_INCLUDED
This is the original file..elif lanigiro eht si sihT Process returned 0 (0x0 excution time 0.234 s Press any key to continue
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
