Here is the code
#include <stdlib.h> #include <string.h> #include <stdio.h> int main () { char str[80]; int i,j,temp; const char s[2] = " "; char *token; char *token2; fgets(str,sizeof(str),stdin); token = strtok(str, s); token2=token; printf("\n%s",token2); while( token != NULL ) { i=0; j=strlen(token)-1; while(i<j){ temp=token[i]; token[i]=token[j]; token[j]=temp; i++; j--; } printf("\n%s",token2); token = strtok(NULL, s); } return 0; } His task, to display all palindromes found in the phrase. But the program does not correctly respond to this insert:
token2=token; If I enter for example the word: the book It displays:
книга агинк Although token2 did not change in the while loop, why is this happening?