'How do I check if every word in a text file is in a dictionary that contains every English word?

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char file(FILE *fh, char c[45]);
int lejiko(FILE *lh);
void split(FILE *fh);

int main() {
    int choice;
    char c[45];
    FILE *fh;
    FILE *lh;
    file(fh, c);
    lejiko(lh);
    split(fh);

    return 0;
}

char file(FILE *fh, char c[45]){
    fh = fopen("test.txt", "r");
    if (fh != NULL) {
        printf("Loaded File");
        /* while ((c = fgetc(fh)) != EOF)
            putchar(c); */
    } else
        printf("ERROR");
    fclose(fh);
    return c;
}

int lejiko(FILE *lh) {
    int count = 0;
    char t;
    lh = fopen("englishWords.txt", "a+");
    if (lh != NULL) {
        printf("\nLoaded Dictionary");
    }

    for (t = getc(lh); t != EOF; t = getc(lh))
        if (t == '\n')
            count = count + 1;

    printf("\nYparxoun %d lejeis sto lejiko.\n", count);
    return count;
}

void split(FILE *fh) {
    char array[45];
    char *spl;

    fh = fopen("test.txt", "r");
    if (fh == NULL)
        perror("Error opening file");
    else {
        while (fgets(array, 45, fh) != NULL) {
            printf("%s\n", array);
            spl = strtok(array, " ");
            while (spl != NULL) {
                printf("%s\n", spl);
                spl = strtok(NULL, " ");
            }
        }
        fclose(fh);
    }
    return 0;
}


FILE:I dont know what this is.im.just.testing.out.

Output: I

dont

know

what

this

is.im.just.testing.out

.

.

This is what I have accomplished so far. I think that the way this will work is by storing every word from the text file and the dictionary in to two matrices and from there by comparing the elements of the matrices.So far i have managed to separate each word whenever there is a space, but when there is punctuation in the text it doesn't seem to work. I have tried multiple ways to remove punctuation from the text, but I cannot get it to work. Also dont mind the functions that just print their names, they will be used for later versions.

c


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source