Reputation: 151
This is supposed to return false if a character in the string isn't a letter or an apostrophe. Any idea why it doesn't work? And is there a better way that I can write it? I'm trying to write code like a C++ purist.
for (std::string::const_iterator it = S.begin(); it != S.end(); ++it)
if ((*it < 'a' || *it >'z') && (*it > 'A' || *it < 'Z') && (*it != ''''))
return false;
Upvotes: 0
Views: 73
Reputation: 183251
I see two mistakes:
''''
should be '\''
.*it > 'A' || *it < 'Z'
should be *it < 'A' || *it > 'Z'
.Upvotes: 7