I made a program to find if a entered string is palindrome or not palindrome but it always says that its not a palindrome
#include
#include
From the 2005 version of myself:
bool isAlphaNumeric(char c)
{
return (iswalpha(c) || iswdigit(c));
}
bool isPalindrome(char *str)
{
/* A man, a plan, Anal Panama!!! */
if(*str == '\0')
{
return false;
}
int len = strlen(str);
if(len <= 1) return true;
char *start = str;
char *end = start + len - 1;
while(start < end)
{
if(!isAlphaNumeric(*start))
{
*start++;
continue;
}
if(!isAlphaNumeric(*end))
{
*end--;
continue;
}
if(towlower(*start) != towlower(*end))
{
return false;
}
*start++;
*end--;
}
return true;
}