471,120 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,120 software developers and data experts.

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 1634
9,065 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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.