Hi,
can you please help me in this task ,please
I split the sentence into words but how can I pass every word to the function and test at
Code:
# include <stdlib.h>
# include <stdio.h>
# include <string.h>
# include <ctype.h>
# define SIZE 100
int ispalindromes(char str[],int length);
void split(char st[]);
int main () {
char st[SIZE],st1[SIZE],*token;
int counter=0,i=0,leng;
gets(st);
token = strtok( st," ");
while (token != NULL) {
printf( "%s\n", token);
token = strtok( NULL, " ");
if(ispalindromes(token,strlen(token){
counter++;
}
}
system("pause");
return 0;
}
int ispalindromes(char str[],int length){
if ( length < 1 )
{
return 1; /* no more chars to compare, its a palindrome */
}
if ( str[0] == str[length-1] ) /* Are the two ends same? */
{
return ispalindromes( str+1, length-2 ); /* continue checking */
}
else
{
return 0; /* comparison failed, not a palindrome */
} }