On Thu, 18 Oct 2012 18:24:37 -0400, "Bill Cunningham"
snip
And let me ask you as a programmer Ian and being in the *in* group an
*outgroup*er question. What exactly do callback pointer functions help with.
I know this should come from the womb but just and honest question.
There are callback functions and function pointers but what do you
think a callback pointer function is?
Consider the common case of qsort. It contains a sorting algorithm
which at some point needs to know what the relationship between to
array elements is. Unfortunately, it doesn't know what the type of
the array elements is and therefore cannot compare them internally.
You provide a compare function which qsort can "callback" to determine
the relationship. The function then returns the status of that
relationship to qsort which makes the appropriate processing decision
based on that status.
In general, callback functions provide a way for a user to tailor a
generic process by providing information specific to the current
application.
In this way the same qsort library function can be used once to sort
an array of pointer to double based on the value of the double and
again to sort an array of struct based on a character array in that
struct.