Recursion function won't exit
Listed below is a recursion function that reads a list of characters for a palindrome. The recursion goes from the inside out to the edges. ( No strings allowed ) . This function reads all the characters fine but won't jump back to the main ().
main () uses one variable which is the number of characters in the palindrome. The function then divives the number by 2 to know how many loops in the recursion and mod 2 to deal with the odd middle character. The function reads all the number fine but never jumps back to main . help!!
bool palindrome ( int half , int mod )
{
char letter1, letter2, oddletter;
bool status = true;
if ( half >= 1 ){
letter1 = cin.get();
cout << letter1;
palindrome ( half--, mod );
letter2 = cin.get();
cout << letter2;
if ( letter1 != letter2 )
status = false;
else
if ( mod == 1 ) {
oddletter = cin.get();
cout << oddletter;
status = true;
}
}
return status;
}