#include<bits/stdc++.h>
using namespace std;
bool isPalindrome(char str[], int l, int r)
{
if(strlen(str) == 1)
return true;
if(str[l] == str[r] && strlen(str)==2){
return true;}
else if(str[l] == str[r]){
char res[r-1];
for(int i = l+1, j = 0; i <= r-1; i++, j++)
res[j] += str[i];
isPalindrome(res, 0, strlen(res)-1);
}
return false;
}
int main()
{
int n;
cin >> n;
cin.get();
char str[n];
for(int i = 0; i < n; i++)
cin >> str[i];
bool ans = isPalindrome(str, 0, strlen(str)-1);
if(ans)
cout << "true" << endl;
else
cout << "false" << endl;
return 0;
}
Could you tell me where I am going wrong in the recursion part?