I must write a program which will be changing a words from one text file basic on dictionary from another text file. For example in "test.txt" i have:
"mama poszla z tata na zakupy"
and in "slownik.txt" i have:
"mama:mother, tata:father, babcia:grandma, na:on,"
I expected to my program disply "mother poszla z father on zakupy", but only first word is changed. Below my code fragment in C:
char *token; 
int k = 0;
while (!feof(slownik)) //
{
    k = 0;
    fscanf(slownik,"%s",&liniatekstu);
    token = strtok(liniatekstu," ,.:");
    while(token != NULL)
    {
       tab[k] = token;
     //  printf("%s\n", tab[k]);
       token = strtok(NULL," ,.:");
       k = k + 1;
    }
    char c;
    char slowo[1000];
    int idx = 0;
    while(!feof(fp))
    {
        c = fgetc(fp); // get sign
        if( ! isspace(c) )
        { // full sign - add to word
            slowo[idx++] = c;
            if(idx>=1000)
            {
                printf("Error - word has > 1000 signs\n");
            }
        }
        else 
        { // blank sign - end of word
        //  if(idx == 0) // idx=0 word is empty
            //  continue;
                // we have final word 
                // - add zero to end of word and display to screen 
            slowo[idx] = 0;
             // printf("%s\n", slowo);
            // TU MAM SLOWO
            const char* x = tab[0]; // polish version of word
            const char* y = tab[1]; // english version of word
            if ( strcmp(slowo,x)  == 0) // comparation word from "test.txt" and "slownik.txt" if its the same display english version of word
            {
                printf("%s ",y);
            }
            else
            {
                printf("%s ",slowo); // display polish version
            }
            idx = 0;
         }
    }
}
Please help.
 
    