fork download
  1. #include <stdio.h>
  2.  
  3. int plus(int a, int b)
  4. {
  5. return a + b;
  6. }
  7.  
  8. int main(void)
  9. {
  10. // f is a pointer to a function with signature int(int, int)
  11. int (*f)(int, int) = &plus;
  12.  
  13. // This does not work -- can't substitute f for an int
  14. // printf("%d\n", f);
  15.  
  16. // This works -- the type of f(1,2) is int
  17. printf("%d\n", f(1, 2));
  18.  
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 4336KB
stdin
Standard input is empty
stdout
3