Ignoring puncuations in input stream
hello, this is my first post, nice to meet everyone
I am taking input from the keyboard, and I want to ignore
whitespace, punctuation and the case of letters, i.e. 'a' = 'A'
I figured out the whitespace, but I can't figure out letter case and
punctuation. Here is my code (my main function, which uses a stack
and queue objects). The program is meant to determine whether or
not a statement is a palindrome.
Code:
#include "stack.h"
#include "queue.h"
#include <iostream>
using namespace std;
int main()
{
bool isPalindrome = true;
char ch, ch1, ch2;
StackType s;
QueueType q;
cout << "Enter a statement: ";
cin >> ch;
while(!s.IsFull() && ch != '\n')
{
s.Push(ch);
q.Enqueue(ch);
if(cin.peek() != '\n')
cin >> ch;
else
cin.get(ch);
}
while(isPalindrome && !s.IsEmpty())
{
q.Dequeue(ch1);
ch2 = s.Top();
s.Pop();
isPalindrome = ch1 == ch2;
}
cout << endl;
if(isPalindrome)
cout << "Entered statement is a Palindrome\n";
else
cout << "Entered statement is not a Palindrome\n";
return 0;
}
thanks!