palindrome recursion

Hi

I'm a beginner, currently I'm working on a program that determines whether a word is a palindrome, in which a word can be spelled backwards and still remain the same ie. MOM, DAD, spelled backwards is still MOM,DAD etc.
However I keep on getting error "Invalid direction" Below is my code. And I also made an attachment of the code as well. I'm trying to figure it out using recursion. Can someone please tell me what is the problem.

cin >> inputString;//receive input from user
last = strlen(inputString);//store input into character array

if (Palindrome(first,last,inputString)== true)
cout << "Input is classified as a palindrome.";
else
cout << "Input is not classifed as a palindrome.";

getch();
return 0;
}

bool Palindrome(int first, int last, char inputString)
{

//if next first element and next last element are not the same
//therefore word is not a palindrome returned as false
if (inputString[first]!= inputString[last])
return false;

//if next first element and next last element are same
//call Palindrome function again, increment first element by one
//decrement last element by one to compare if those two elements
//in array are equal.Continue this process until next first element
//and next element are not equal.
else if (inputString[first] == inputString[last])
{
Palindrome((first+1),(last+1),inputString);
return true;
}
//if the next first index is greater than the next last index
//program concludes that all the elements in array have been compared
//and therefore input should be a palindrome retuned as true.
else if (inputString[first] > inputString[last])
{
return true ;
}
}

//decrement last element by one to compare if those two elements
//in array are equal.Continue this process until next first element
//and next element are not equal.
else if (inputString[first] == inputString[last])
{
Palindrome((first+1),(last-1),inputString);
return true;
}

it didnīt read the full code, but if it still does not work, i will ;)

[edit]
sorry, you probably cannot see that the "-" is highlighted (for me in IE6, i cannot). you have "+" there...
and i think i found another error:
else if (inputString[first] > inputString[last])
imho should be
else if (first > last)
and you need to redo your if-construction because of this...
if you would use the [ code ] tags and ident your code, it would be much easier to see that the line as you typed it is never evaluated since "inputString[first] != inputString[last]" precedes "inputString[first] > inputString[last]"
(there is no three boolean states ;) )
[/edit]

Two errors here. First it should be (last - 1) instead of (last + 1). Also you're completely ignoring the return value of Palindrome when you're recursing into the function and arbitarily returning true. So if your input string is "foef", the function will still return true. You should modify it to:

This should be if (first > last) and also this should be the first thing checked in the function before you check anything else. Otherwise, there is a chance that one of the other if checks will be satisfied earlier and this code will never be executed.

Here's the corrected code. Note that it is still not technically correct, because it is not case-insensitive, but that is left as an exercise for you to complete:

Code:

#include <iostream.h>
#include <conio.h>
#include <string.h>
using namespace std;
//---------------------------------------------------------------------------
bool Palindrome(int first, int last, char inputString[]);
int main()
{
int first = 0;// first index for array
int last = 0;// last index for array
char inputString[100];//initialize size of array
cout << "This program determines whether the word"
<< endl
<< "or sentence entered by user is a palindrome."
<< endl;
cout << "\n\nPlease enter a word or phrase: ";
cin >> inputString;//receive input from user
last = strlen(inputString);//store input into character array
if (Palindrome(first,last - 1,inputString)== true)
cout << "Input is classified as a palindrome.";
else
cout << "Input is not classifed as a palindrome.";
getch();
return 0;
}
bool Palindrome(int first, int last, char *inputString)
{
//if the next first index is greater than the next last index
//program concludes that all the elements in array have been compared
//and therefore input should be a palindrome retuned as true.
if (first > last)
return true;
//if next first element and next last element are not the same
//therefore word is not a palindrome returned as false
if (inputString[first]!= inputString[last])
return false;
//if next first element and next last element are same
//call Palindrome function again, increment first element by one
//decrement last element by one to compare if those two elements
//in array are equal.Continue this process until next first element
//and next element are not equal.
else if (inputString[first] == inputString[last])
{
return Palindrome((first+1),(last-1),inputString);
}
}

Heh, I had the same assignment in my Comp Sci class a few years back, but I went about it differently. I had two arrays, string[], and string_reverse[], string_reverse was populated through a for loop that put string[x] into string_reverse[strlen(string)-x], then another for loop to compare the two strings to each other, if they're the same, then it returns true. I do like the way you did it though :D