Function Pointer in C

Function Pointer in C

In this program, you will learn about the function pointer and get the example code of function pointer in c programming.

What is Function Pointer in C

A function pointer is a pointer which stores the address of a function. It is used to call a function indirectly in C programming. Function pointers are mainly used for callback functions in C programming. A callback function is a function which is called by another function.

Syntax

<return_type> (*function_pointer_name)(parameter_list);

For ex. – You have a function like numberSum that takes two int as parameters and returns an int, you can make a pointer to it like this:

int (*sumPointer)(int, int) = &numberSum;

Function Pointer in C example

Output

Addition = 60

Substraction = -20

 

 

Check out our other C programming Examples

 

 

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top