when i debug this C code, the code is used to read text from txt file and save to the binary tree, the variable 'x' do not create new after a loop, and it stills save the variable of the previous loop to use in the next loop,so sometime in some case it make the duplicate values at the end of while loop. i use Visual Studio 2013 to code sorry for my bad english.
void createtree(btree &t)
{
initbtree(t);
FILE*f;
f = fopen("input.txt", "r");
while (!feof(f))
{
data x;
fgets(x.word, 20, f);
x.word[(strlen(x.word) - 1)] = '\0';
fgets(x.mean, 20, f);
if (x.mean[strlen(x.mean)-1] == '\n')
x.mean[(strlen(x.mean) - 1)] = '\0';
tnode*p = createtnode(x);
insertnode(t.root, p);
}
fclose(f);
printf("Create Tree done!\n");
}