hi
my problem is that i want to return true when the string are same when they are written in backwards
like noon=noon or radar=radar.
if they arent same then return false....but my code is always returning false.
bool isPal(string);
int main()
{
string A;
cout<<"please enter the string that you want to check :"<<endl;
cin>>A;
isPal(A);
if(isPal(A)==true)
cout<<"the string parameter is palindrome"<<endl;
else cout<<"the string parameter is not palindrome"<<endl;
getch();
return 0;
}
bool isPal(string A)
{
string b;
int i ;
int length=A.length();
for(i=length;i>length;i--)
{
b[i]=A[i];
}
cout<<b;
if (b==A)
returntrue;
elsereturnfalse;
}
bool isPal(string A)
{
string b;
int i ;
int length=A.length();
for(i=length;i>length;i--)
{
b[i]=A[i];
}
cout<<b;
if (b==A)
returntrue;
elsereturnfalse;
}
i dont want it to b always equal wht i want is that i want to save string A in reverse order in string b then i have to compare it wether they r same or nt.......
The mistake you're making is in the copying of letters from one A to b. All you're doing is making an exact copy. You need to copy the letters starting at the END and then backwards.