int palin(char array)
n = array;
/* I don't know what u mean with (char *) = (char). How exactly would i code that?
/* here i'm dividing the length of the array by 2, then comparing the first char of the array with its opposite char in the array, if they match then it moves to the next char*/
if (n <= strlen(array)/2)
strlen return the lenght of a string */[/COLOR]
if (array[n] == array[strlen(array)-n-1])
else return 0;
int main() // Hum, function name should be main
printf("Enter a string (20 characters max): ");
/* In fact, if the user enter 20 characters, you'll have buffer overflow */
/* You shouldn't use gets; use something like fgets(array, 20, stdin),
or better, fgets(array, sizeof(array) / sizeof(*array), stdin) */
i = palin(array);
if ( i!= 0) printf("Is a palindrome");
else printf("Is not a palindrome");
Think about rewriting your palindrome function prototype to something like
where n is the number of characters in the string, and make recursive call like
int palin(char *array, int n);
By the way, normal recursive function always have a similar pattern. First, you test if you'll converge by calling recursively the function, then you check if you are in a "base case", else you call your function recursively with a smaller set than the original call... for example, in your case...
palin(array + 1, n - 2);
well in fact i won't post an example since it will mostly give you the answer...[/QUI explained what I'm trying to do with the recursion. Could you clarify the part about the pointer? Also I'm going to avoid fgets because we haven't learned that yet.