A string consisting of words, no longer than 100 characters, is supplied. Words consist of Latin characters and are separated by a single space. It is necessary to output to the standard output stream a string containing only the words palindromes. The source data must be read into memory as a whole and all manipulations must be carried out in memory, the result obtained in memory and then printed.
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int check(char str[])
{
    int i, length;
    length = strlen(str);
    for (i = 0; i < length; i++)
        if (str[i] != str[(length - 1) - i]) return 0;
    return 1;
}
int main(void)
{
    char str[100];
    char* t;
    gets(str);
    t = strtok(str, " ");
    while (t != NULL) {
        if (check(t) == 1) {
            printf("%s ", t);
        }
        t = strtok(NULL, " ");
    }
    _getch();
    return 0;
}
this is my code (it fails the tests) Please help me fix the code
 
     
    