Calling Functions

Learn how to call a function using its address.

We'll cover the following...

Let’s see how we can call a function using its address in memory.

Example program

Press + to interact
# include <stdio.h>
void display( ) ;
int main( )
{
void (*p)( ) ;
// One way
display() ;
p = display ;
// Two more ways
( *p )( ) ;
p( ) ;
}
void display( )
{
printf ( "Hello\n" ) ;
}

Explanation

Normally a function is called using its name, such as the call, display( ), in the code above.

We ...