if(htbalance)
printf("tree is height balanced\n");
Here you only check whether htbalance
, a pointer to a function, is NULL or not. Of course it is non-NULL, and thus you always get true.
You should call htbalance()
and check its return value.
if (htbalance(tree))