i have to write a program that checks a palindrome to see if it is in fact a palindrome but i get this warning
warning C4800: 'char *' : forcing value to bool 'true' or 'false' (performance warning)
and its not quite working
any help would be great thanks.
#include <iostream>
using namespace std;
const MAX=20;
void getSent(char array[MAX]);
bool palindrome(const char array[MAX]);
int main()
{
char array[MAX];
cout << "Enter you palindrome: ";
getSent(array);
bool palindrome(array);
if(palindrome == true)
cout << "yes " << array << " is a palindrome";
return 0;
}
void getSent(char array[MAX])
{
char pal;
int index = 0;
cout << "Enter you palindrome: ";
while ((pal = cin.get() != '\n') && (index < (MAX - 1)))
{
array[index] = pal;
index ++;
}
array[index] = '\0';
cin.ignore(1000,'\n');
}
bool palindrome(char array[MAX])
{
int end, start,i = 0;
while(array[i] != '\0')
{
array[i] = tolower( array[i] );
i++;
}
while(array[i] != '\0')
{
if (!isalpha(array[i]))
i--;
}
for(end = 0;array[end] != '\0';end ++);
for (start = 0; start < end;)
{
if (array[start] != array [end])
{
return false;
}
start ++;
end --;
}
return true;
}