Hello,
here is my problem. I have a dictionnary of words (e.g., type
char[N]) stored sequentially (but not sorted) in a file F and I want
to insert in it some words stored in memory in a balanced tree T.
some elements of T may already be in F and I do not want to have them
twice in F after insertion.
i want to do something like this:
for each word in F
- if word is in T
-- remove word from T
for each word in T
- append word to F
here is how I implemented it :
1 - open F in "r" mode
2 - read sequentially (with fread) the words in F and delete them from
T
3 - close F
4 - open F in "a" mode
5 - append (with fwrite) to F all the remaining words of T
6 - close F
my questions are:
1 - is this an efficient way to do, and is there a better way?
2 - are there any trick to know to improve efficiency?
Thanks for help