hi i was trying to use this function to take out palindromes and make a new string with them but i get core dumped
i don't see any problem with code really it is complicated because i use so many parameters but i don't think that will make it wrong what do you think?
the result should be "noon i 313 a kayak"
char* Palindroms(char* str){
int size = strlen(str);
char *wordptr;
char *revword;
char *stringptr = malloc(size+1);
for(int i = 0;i < size;i++){
int j = 0;
int k = 0;
while(*str != ' '){
wordptr[j] = *str++;
i++;
}
while(j != 0){
revword[k] = wordptr[j];
j--;
k++;
}
if(revword = wordptr)
strcpy(stringptr + k,revword);
}
return stringptr;
}
int main(){
char string1[] = "yesterday noon i paid 313 shekels for a new kayak";
char *string3 = Palindroms(string1);
printf("%s", string3);
return 0;