the question is
A palindrome is a string that is read the same in both directions, for example, racecar, eye, etc. Write a program in
that prompts the user to enter a string and uses a recursive function to determine if the given input is a palindrome
i have done this so far but its not working guys :
#include<stdio.h>
#include<conio.h>
#include<string.h>// to save string
int isPalindrome(char*str);
int main (void)
{
int result;
char str[50];
printf("\n pls enter string; \n");
gets(str);
result = isPalindrome(str);
if(result ==1)
{
printf("\n input string in a palindrome string ");
}
else
{
printf(" not a palindrome");
}
getch();
return 1;
}
int isPalindrome(char*str)
{
static int length = strlen(str);
if(length<1)
{
return 1;
}
if(str[0]=str[lenght - 1])
{
length-=2;
}
return isPalindrome(str + 1)
}
{
return 0;
}
Since you tagged your question as C++, this approach would work: