Monday, May 1, 2017

Function Pointer

Pointer to a function is declared as follows

void (*fn)()

Void is the return type
fn is the function name
() is the parameter types

For example

int (*abc)(int, int) is a function pointer for a function abc which accepts 2 integer arguments and returns an integer result

To use a function pointer

int sum(int a, int b)
{
    return a + b;
)

abc = sum;
z = abc(x, y);


No comments: