i'm trying to write a program where i use one stack and one queue, each of size 10, to find strings that are palindromes (spelled same forward and backward). i have my ItemType.h, Stack.h, Stack.cxx, Queue.h, and Queue.cxx all done. it is my driver that i'm working on now so i can put it all together but its confusing me. here's what i have so far:
also, i'm pulling from my info i have to compare from a file (hence, "infile") and implemented exception handling as well. so far this thing runs...just that my oufile displays everything in it straight down a page...not even attempting to compare it out output it nicely yet.Code:#include <iostream.h> #include <fstream.h> #include <iomanip.h> //#include <cctype.h> #include "stack.h" int main() { ifstream infile; ofstream outfile; infile.open("in.data"); outfile.open("out.data"); outfile.setf(ios::fixed,ios::floatfield); outfile.setf(ios::showpoint); outfile << setprecision(2); ItemType item; StackType s; while(infile>>item) { try { s.Push(item);} catch (PushOnFullStack error) { outfile << "Error!" << endl; exit(1); } } while(!s.IsEmpty()) { try { s.Pop(item); outfile << item << endl;} catch (PopOnEmptyStack error) { outfile << "Error!" <<endl; exit(1); } } cout<<"done for chstack"<<endl; return 0; }
i'm just stumped on how to also implement the whole "queue" part in the driver so i can use it along with stack in comparing these strings of text i'm looking at.
any help or hints at all would be appreciated, and if i'm being too broad in what i wrote or not clear enough, i'm sorry.