This is some code that determines if a string of characters is a palindrome or not. My professor says that there is a performance issue with the program, but I can't quite put my finger on it. Can someone find out the 'performance' issue?
Initially, I thought maybe the process is slower as it uses two memory containers, as opposed to simply comparing two halves of a single string.
int main()
{
char c;
bool check = true;
stack<char> cstack;
queue<char> cqueue;
cout << "Enter a string and press return." << endl;
cin.get(c);
while (c != '\n') {
cstack.push(c);
cqueue.push(c);
cin.get(c);
}
while (check && !cqueue.empty()) {
if (cstack.top() != cqueue.front())
check = false;
cstack.pop();
cqueue.pop();
}
if (check)
cout << "Yes it is!" << endl;
else
cout << "No it's not." << endl;
return 0;
}