C++ Ignoring Special Characters, Upper and Lower Characters in a String

Hello,

I'm a newbie, and I'm doing this assignment. I need help with simple function or a statement that will ignore if user inputs special characters in a string.

This assignment is about Palindromes.

If user inputs "bob" it should say, and it already does say that it is a Palindrome.

However if user enters upper case with lowercase i.e (Bob)
Program is supposed to output it is a palindrome. But mine says it is not beacause of the Uppercase letter 'B'. I searched the forum and found the below piece of code. Unfortunately it doesn't work.

 
  testSentence.resize(remove_if(testSentence.begin(), testSentence.end(),[](char x){return !isalnum(x) && !isspace(x);})-testSentence.begin());


Please help!

Thanks in advance
Unfortunately it doesn't work.


If you present a snippet of code and say "it doesn't work" that isn't helpful. If you need to take your car to a mechanic to address a problem, do you think he'd be satisfied with "it doesn't work" or do you think he might like a more detailed explanation of the symptoms you're experiencing?

The snippet you posted doesn't attempt to solve the problem you say you're trying to solve. Where in that snippet do you see an attempt to deal with letters of differing case?
Topic archived. No new replies allowed.