Q:

what do you mean by registering a callback function in C?

Can anyone please tell me what do we exactly mean by registering a callback function in C with some examples? I have searched a lot in the net, but I couldn't get a satisfactory answers. Even searched in stack overflow but couldn't get the perfect idea about it.
What are Notify callbacks and Asynchronous call backs?

A:

Registering a callback function simply means that you are arranging for an external entity to call your function.
It might happen at a later time, or it might happen straight away. A straightforward example is qsort. It is declared like this:
void qsort(void *base, size_t nel, size_t width,
       int (*compar)(const void *, const void *));

In order to use it, you must pass a pointer to a function that compares elements - the callback.
That was a simple example but generally "registering a callback" means passing a function pointer to someone who will call it for you in the future.

A:

Registering a callback means to pass a function pointer to the one who will call your function through the pointer
For easier understanding Consider A and B who are two entities involved in the code.
A has written a function say myFunc
char myFunc(int a)
{
/* Code written by A*/
}

Now when it is said A will register a callback with B, it means A will send the function pointer to B
By sending function pointer to B, A provides an access to the function
To register the callback there will be a function where A can pass the pointer
A will call the function as
cb_register(myFunc);
// Passed the address of Function

This cb_register function is defined in B as
typedef void (*cb_fn_ptr)(int a);

void cb_register(cb_fn_ptr cb)
{
    // In this function B can store the address in a structure member

}

For example a struct_B is declared which stores
struct s_B {
    cb_fn_ptr cb;
    // cb will have address whenever B 
};

B has stored the address (which the function pointer points to) and can use it to call the function later.
When B calls the function through the function pointer it is called as callback.
B just needs to know the prototype of the function to call the function and can be completely unaware of what the function does.
In this case function will call as
struct s_B temp;
char ret_val;
int arg_val;
ret_val = temp->cb(arg_val)
//This is a callback

