42_function_pointer.c 418 B

1234567891011121314151617181920212223
  1. #include <stdio.h>
  2. int fred(int p)
  3. {
  4. printf("yo %d\n", p);
  5. return 42;
  6. }
  7. int (*f)(int) = &fred;
  8. /* To test what this is supposed to test the destination function
  9. (fprint here) must not be called directly anywhere in the test. */
  10. int (*fprintfptr)(FILE *, const char *, ...) = &fprintf;
  11. int main()
  12. {
  13. fprintfptr(stdout, "%d\n", (*f)(24));
  14. return 0;
  15. }
  16. /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/