Answers for "how to declare a pointer to a function"

C
1

Function Pointer

#include <stdio.h>
// A normal function with an int parameter
// and void return type
void fun(int a)
{
    printf("Value of a is %dn", a);
}
  
int main()
{
    // fun_ptr is a pointer to function fun() 
    void (*fun_ptr)(int) = &fun;
  
    /* The above line is equivalent of following two
       void (*fun_ptr)(int);
       fun_ptr = &fun; 
    */
  
    // Invoking fun() using fun_ptr
    (*fun_ptr)(10);
  
    return 0;
}
Posted by: Guest on January-05-2022
-2

passing a pointer to a function

/**
* myFunction - a function that recieves an integer pointer
*/

void myFunction(int *param) {
   .
   .
   .
}
Posted by: Guest on August-04-2021

Code answers related to "how to declare a pointer to a function"

Code answers related to "C"

Browse Popular Code Answers by Language