By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,159 Members | 888 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,159 IT Pros & Developers. It's quick & easy.

tsearch questions

P: 9
Does anybody can tell me the following answers?
In the description of tsearch function, what is purpose of the callback function( compar) as follows:
void *tsearch(const void *key, void **rootp,
int(*compar)(const void *, const void *));

also, basicly what are the two parameters in the function (compar)?
Jul 11 '06 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 8,916
I imagine that the purpose of compar is to compare the 2 values passed to it probably returning

-1 if parameter 1 is less than parameter 2
0 if parameter 1 equals parameter 2
-1 if parameter 1 is greater than parameter 2

This could be used to search within a tree presumably of the key value.
Jul 12 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.