Data structure for french-english dictionary
I am trying to make a french-english dictionary of simple word-word correspondence (I don't need the meaning). However, as I have thought about it, I will probably need some additional tags like
a) Linguistic category (noun, verb, adjective)
b) Type category (household, numerical, time, work, shopping)
Eventually I will try to use this as a data storage for use in a graphical program where I can select a category and it will display random words from that category.
With my current level of understanding I have thought of two options:
1. Created a multidimensional array
e.g.
Code:
char dictionary[100][2][20]
2. Create a struct
(I have never implemented a struct within a struct, so the following might not be great...)
Code:
typedef struct{
char french[20];
char english[20];
char type[20];
char category[20];
}wordpair;
typedef struct{
wordpair word[100];
int length;
}dictionary;
or more simply
Code:
typedef struct{
char word[100][2][20];
char dictionaryName[20];
int length;
}dictionary;
At one level the data structure does not need to be too complicated as it's simply for me and my partner to add words as we go along - I don't need to popuate it with the entire vocabulary, just a few at a time.
I realise neither of these is especially elegant in that I am setting aside a whole blob of memory without necessarily using it. However, I'm still not completely confident with malloc/realloc/free yet.
I'm about to learn something about C++ (especially classes) and am dimly aware also of somethings called vectors and binary trees - would these be a better way to go?
My questions are about
a) Improvement of existing ideas - how might I better implement the data structure using either arrays or structs
b) Advanced (for me that is) - what other techniques might people use, is there a generally agreed "best way" to implement a language dictionary in C.
Thanks