I
I
Ivan Yakushenko2016-05-10 16:30:02
C++ / C#
Ivan Yakushenko, 2016-05-10 16:30:02

How to compare a word from a text for its presence in a C dictionary?

There are text files text.txt and dictionary.txt with the corresponding information in them, you need to find words with errors in the text, that is, those that are not in dictionary.c. Initially, 3 files were given: dictionary.h, dictionary.c and speller.c.
In speller.c ( link to it ) there are functions for loading text into the text variable, a function for parsing text into words and saving it to the word variable, as well as functions for measuring the time spent loading a dictionary, the number of words in the text and dictionary, erroneous words and output it all to the console. dictionary.c ( link to it) was initially empty, except for the declared functions check, load, size, unload which I need to write. Check should compare words from the dictionary and text, load should load the dictionary into memory, size should give the number of words in the dictionary, and unload should unload the dictionary. dictionary.h ( link to it ) acts as a link library.
The main problem is that there is no way I can get data from the text and word variables from speller.c to dictionary.c. In the load function, I open the dictionary with the fopen(dictionary, "r") function, the dictionary variable itself stores a reference to dictionary.txt, which is passed as a command line argument when speller.c is launched and it is initialized in speller.c itself and there are problems accessing it there are none from dictionary.c, but for some reason I can’t use the text and word functions, even if I write 100% similar code as in the load function. So, how is it possible to compare words with all this without modifying dictionary.h and speller.c, or, at least, with minimal modifications?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Gromov, 2016-05-10
@riivers

I've read it 10 times and still don't understand anything.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question