if (length == 2)// at is for array and pointent ta begin and end
{
if (name.at(0) == name.at(1))
return true;
else
return false;
}
if (name.at(0) == name.at(name.length() - 1))
{
name.erase(name.end()-1); // earse last charcter from string
name.erase(name.begin()); // earse first charcter from string
return isPal(name); // ** recursion part
}
else
return false; // last one to check if all above aren't true
}
I am new to proggraming and having an error in return temp line. I don't know the cause of the error. The compiler says cannot convert std string to int in return. I saved the temp as name so why does it still have the error
2) temp is a string. But main() is - quite correctly - defined to return an int, not a string.
Why are you trying to return a string from main()? What are you trying to achieve by that? Do you understand what happens to the value returned from the main() function of a program?