468,456 Members | 1,654 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,456 developers. It's quick & easy.

tsearch questions

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
1 1565
Banfa
9,051 Expert Mod 8TB
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.

Similar topics

reply views Thread by Joerg Erdmenger | last post: by
3 posts views Thread by Joerg Erdmenger | last post: by
13 posts views Thread by Nigel J. Andrews | last post: by
1 post views Thread by sector119 | last post: by
4 posts views Thread by Bas Scheffers | last post: by
2 posts views Thread by Rajesh Kumar Mallah | last post: by
reply views Thread by softwareengineer2006 | last post: by
reply views Thread by connectrajesh | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.