You are here:

C/what is use of function pointer


I ve knowledge, how to make a pointer to a function.But,
what is use of function pointers in C language.
What is generic functions mean and how it is helpful?plz it would be better if you will explain with example.
Thank you

Hi Shaktikanta,
Function pointers can be useful when you want to create callback mechanism, and need to pass address of a function to another function.
A callback function is one that is not explicitly called by a programmer. Instead there is some mechanism that continually waits for event to occur, and it will call selected functions in response to particular events.
This mechanism is typically used when a operation(function) can take long time for execution and the caller of the function does not want to wait till the operation is complete, but does wish to be intimated of the outcome of the operation.
Function pointers can also be useful when you want to store an array of functions, to call dynamically for example.

A generic function is a function that is declared with type parameters. When called, actual types are used instead of the type parameters.  


All Answers

Answers by Expert:

Ask Experts


Kedar Desai


You can ask me any questions about C and c++


I don't have practical experience. But i have knowledge about C as I belong to IT field since last 5 years.

I an studying in MCA from Maharashtra (Mumbai University)

©2016 All rights reserved.