Home C C++ Java Python Perl PHP SQL JavaScript Linux Selenium QT Online Test

Function Pointer in C Programming

A function pointer in C programming is a special type of variable which holds the address of a function, this function can be called using that function pointer.

Usage of Function Pointer

  • Functions as Arguments to other functions
  • Callback Functions

Functions as Arguments to other functions

We can pass functions as arguments to other functions in C programming. The syntax of function pointer is -

void (*fptr)(int);

In the above syntax fptr is a function pointer which can store address of a function which takes one argument int and returns void.

int (*fptr)(int, int); 

Here fptr is a function pointer to a function which takes one int argumetns and also return int value. Example of Function Pointer



Callback Functions