Unable to understand the code fragement

S

shan_rish

Hi Group,

I am not able to understand the following code fragement (a return
statement of a function). bsearch is a binary search function and the
(CompareFunction)RnDtsComparitor) parameter is the one which i dont
understand. Any help is appreciated.


//typedefed in a seperate file
typedef int (*CompareFunction)(const void*,const void*);

//Doubt fragement
return (RnDts*) bsearch(&key,
TrffDt.RnDtsDt,
TrffDt.cnt[RNDTCNT],
sizeof(RnDts),
(CompareFunction)RnDtsComparitor);

I dont know if any other information is needed. If needed i will post
the needed information also.
Cheers
Shan
 
S

Srini

Hi Group,
I am not able to understand the following code fragement (a return
statement of a function). bsearch is a binary search function and the
(CompareFunction)RnDtsComparit­or) parameter is the one which i dont
understand. Any help is appreciated.

It is a pointer to a function that would be used by 'bsearch' to
compare 2 values while doing the sort. Provision to provide a
comparison function through a function pointer is what makes it
possible to sort different types of data.

Srini
 
S

shan_rish

Thanks...
Cheers
Shan
It is a pointer to a function that would be used by 'bsearch' to
compare 2 values while doing the sort. Provision to provide a
comparison function through a function pointer is what makes it
possible to sort different types of data.

Srini
 
S

shan_rish

Srini said:
It is a pointer to a function that would be used by 'bsearch' to
compare 2 values while doing the sort. Provision to provide a
comparison function through a function pointer is what makes it
possible to sort different types of data.

Srini

Thanks...
Cheers
Shan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top