Introduction
C is a general-purpose programming language. C is commonly used in operating systems, device driver code, and protocol stacks. The C programming language is not to be confused with the C++ programming language, which is an extension of the C programming language.
A callback function is any function that receives the reference of another function as the argument to call the function. We can call a callback function using the function pointers in the C programming language. We can also use the STL(Standard Template Library) Functors in C++ to create callback functions.
You can also read about C dynamic array, C Static Function
Example
Let us look at examples of the callback functions in the C programming language,
#include<stdio.h>
void passFunction()
{
printf("Function to be passed\n");
}
void callBackFunction(void (*ptr)())
{
(*ptr) ();
}
int main()
{
void (*ptr)() = &passFunction;
callBackFunction(ptr);
return 0;
}
In the above example, we pass the passFunction as a reference to the callBackFunction and print the value using the callBackFunction.
Also Read About, Sum of Digits in C, Tribonacci Series and Short int in C Programming
Must Read what is storage class in c and Decision Making in C