Advertisement
Jambix64

Function Pointer

Sep 23rd, 2016
1,329
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. void my_int_func(int x)
  3. {
  4.     printf( "%d\n", x );
  5. }
  6.  
  7. int main()
  8. {
  9.     void (*foo)(int);
  10.    
  11.    
  12.     /* the ampersand is actually optional */
  13.     foo = &my_int_func;
  14.    
  15.     foo (5);
  16.    
  17.     foo (60);
  18.     foo (70);
  19.     foo (60);
  20.     foo (92);
  21.    
  22.     return 0;
  23. }
Advertisement
RAW Paste Data Copied
Advertisement