Home / Questions / What is a pointer to a function? Give the general syntax for the same.
Explanatory Question

What is a pointer to a function? Give the general syntax for the same.

👁 1,255 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

A pointer holding the reference of the function is called pointer to a function. In general it is declared as follows.

T (*fun_ptr) (T1,T2…); Where T is any date type.

Once fun_ptr refers a function the same can be invoked using the pointer as follows.

fun_ptr();
[Or]
(*fun_ptr)();