practical use of function pointer
I understand that function pointer is pointer in c language that can store the address of a function, and can be use in call back
simple code
Code:
#include <stdio.h>
void foo()
{
printf(" Welcome ");
}
int main()
{
void (*fp)() = &foo;
// foo();
fp();
return 0;
}
if i use function pointer or function name I get same result
Could you please provide some clarity on why and when function pointers are commonly used ?
I'd appreciate any examples you could offer to help me grasp their usefulness ?