Example #1
0
int main () {

   int value;

   int (*function_ptr) ();


   // function_ptr points to func_one
 
   function_ptr = func_one;

   printf ("\nfunction_ptr @[0x%08x] is 0x%08x\n", &function_ptr, function_ptr);
   value = function_ptr();
   printf ("value returned was %d\n", value);

   // function_ptr points to func_two

   function_ptr = func_two;

   printf ("\nfunction_ptr @[0x%08x] is 0x%08x\n", &function_ptr, function_ptr);
   value = function_ptr();
   printf ("value returned was %d\n", value);

   printf ("\n");
   return 0;
}
Example #2
0
int main(){
    int value;
    int (*function_ptr)();

    function_ptr=func_one;
    printf("function_ptr is 0x%08x\n",function_ptr);
    value=function_ptr();
    printf("value returned was %d\n",value);

    function_ptr=func_two;
    printf("function_ptr is 0x%08x\n",function_ptr);
    value=function_ptr();
    printf("value returned was %d\n",value);
}