The purpose of this code is to determine whether s1 and s2 are palindromes using bool isPalindrome and int length = strlen(cstr). Why is this not working? What are the issues here?
#include<iostream>
using namespace std;
bool isPalindrome(char*cstr);
bool isPalindrome(char*cstr)
{
int length = strlen(cstr);
int temp, arr[length];
int j = length - 1;
for (int i = 0; i < j; i++) {
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
j--;
}
if ((arr[length] = *cstr))
return true;
else
return false;
}
int main ()
{
char s1[50] = "neveroddoreven";
char s2[50] = "notapalindrome";
cout<<isPalindrome(s1)<<endl;
cout<<isPalindrome(s2)<<endl;
return 0;
}