Hi, I need help writing a program that allows you to read an English-French dictionary into two arrays. The English words are stored in one file alphabetically while the French words are stored in the other file corresponding to the English words. This means that the program would ask the user to type a random word and then it would print its French equivalent. The dictionary has to store up to 50 words and use the following function prototypes:
I'm using Word Length equals to 30. Look, it seems like a lot but I don't want the full answer, pseudo-code or even the format would be fine because I'm really at a loss at how to start thanks to my professor's lack of any teaching ability. Asking for help from him always leads to a look like you're some kind of jerk.
- make a text file (*.txt) as the dictionary
- make a fstream variable (or ifstream) to search through the text file
- search from the beginning every time make a new searching
I would read the text files just the once, into arrays, and then search them, rather than rescanning the text files.
Where did the function prototypes come from? Are they fixed for your exercise?
Do you know how to read a text file into an array, line by line?
Do you know how to use a loop to output the values stored in an array?
Do you know about string comparison?
Andy
PS I assume your'e not familar with/allowed to use STL classes like string or vector?
Yes the function prototypes are fixed for this exercise.
Well I did use the fstream method for one other exercise where it would read the contents of one file and output those same contents to another. My professor did go over strings but I didn't really grasp it since he blew past the lesson in 30 minutes and then made us go home. Can't say I know about the loop to output stored in an array.
Well, I don't think I can provide a specific response to such an open question.
But I would look at solving read_in and write_out first, then worry about the other two.
search_words() should also be easy enough; it just needs to find a translation, as your orig post says (you ask the user for an English word then find and display the French eqiv.)
But the point of sort_words() is unclear to me as the input file starts off sorted.
The function signatures suggest you need to use arrays, rather than strings. But I suggest you use a const for the word length in case you decide 30 doesn't work.
Messed with databases at all? Throwing a ton of words into a database, or connecting a database to a larger online database might be worth looking into
Some of the information you need is in the references I posted (inc. some liftable code!). You are unlikely to get anymore info till you show a bit more evidence of effort.
Of course, you could be lucky. There are some people who are prone to spoon feed!