Hello everyone, I've recently learned about queues and fully understand that they follow a fifo order as opposed to stacks that follow a filo order. I am now trying to write a program that will check a word entered in a queue and a stack to see if the are both the same forwards and backwards. I began writing the program and testing it as I went along but am having problems. I was going to complete the main part of the program but kept receiving 3 error messages. I've included the .cpp file below and will include the stack/header file in a quick reply. Does anyone have any suggestions? I wanted to get this part working with a user input just so I could go on to the next step and have it read from a document and write to another one (infile, ios::..., outfile...). This has been driving me crazy but I've managed to complete most of it thanks to all of your help with my previous problem (Reverse output (stack)).
Please let me know if you have any suggestions
*Error Message
--------------------Configuration: palindrome3 - Win32 Debug--------------------
Compiling...
palindrome3.cpp
c:\documents and settings\steve\desktop\palindrome\palindrome3.h(8) : error C2146: syntax error : missing ';' before identifier 'Stack'
c:\documents and settings\steve\desktop\palindrome\palindrome3.h(8) : error C2501: 'Class' : missing storage-class or type specifiers
c:\documents and settings\steve\desktop\palindrome\palindrome3.h(8) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
palindrome3.obj - 3 error(s), 0 warning(s)
Code:# include "palindrome3.h" # include <iostream.h> void blankspace(char *s, char *t) {while (*s!=NULL) {if (*s!=' ') *t=*s;t++ s++; } *t=NULL; //append NULL to newstring } void main () {const int True=1, False=0; // create stack object to store string in reverse order. Stack S; char palstring[ 80] , blankspacestring[ 80] , c; int i=0; // string pointer int ispalindrome=True; //we'll stop if false // get input cin. Getline(palstring,80,'\n'); //remove blanks blankspace(palstring,blankspacestring);// A[],the array;A pointer to A[] //push character onto stack i=0; while(blankedspacestring[i] !=NULL) { S.Push(blankspacestring[i] ); i++; } //now pop one-by-one comparing with original i=0; while (!S.StackEmpty()) { c=S.Pop(); //get out of loop when first nonmatch if (c!=blankspacestring[i]) {isPalindrome=False; break; } // continue till end of string i++; } //operation finished. Printout result if (ispalindrome) cout<<"\"<<palstring<<"\"<<"is a palindrome<<endl; else cout<<"\"<<palstring<<"\"<<"is not a palindrome<<endl;



LinkBack URL
About LinkBacks



The basic idea is this:
I used to be an adventurer like you... then I took an arrow to the knee.