1. strings again

you guys are gonna start hating me real quick but im sorry i have another question. I'm trying to write a program that will notice if a string is a palindrome or not (probably spelled that wrong). i.e anna, or racecar. thanks to anyone that helps and doesn't get too ........ed at me already.

2. Well, my solution to this problem involved getting the length of the string. Scan every member of the array you store the string in up to the midpoint, pushing it into a stack.

If the string is odd, skip the center letter (i.e., if the string is 5 letters long, we can skip the third letter), and pop an item off the stack, and compare it to the element in the array (in this instance the 4th letter).

Basically the same thing for even sized strings, except you don't have to skip the middle letter.

A stack is an ideal data structure for this because it basically stores the string in reverse. The trick is figuring out where to stop pushing, and where to start popping and comparing.

starX
www.axisoftime.com

3. well here is my code, but i can only get it to return 0 and not 1.
int palindrome(char str[]);
int main()
{

char str[20];

int temp;
int retval;
printf("enter a string that is a palindrome:");
fgets(str,sizeof(str),stdin);

temp=palindrome(str);

system("PAUSE");
return 0;
}
int palindrome(char str[])
{
int i, j, retval;

i = 0;
j = strlen(str);
retval = 1;
while (i <= j)
{
--j;
if (str[i] != str[j])
{
retval = 0;
break;
}
i++;
}
printf("%d", retval);

return retval; // return 1 if str is a palindrome, else return 0
}

4. May I suggest a search here and at google as I have seen answers to the palindrome problem a few times before.