Guest User

Untitled

a guest
Feb 20th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. // sfp = pointer to function that returns char* and takes char* as arg
  4. typedef char* (*sfp)(char *s);
  5.  
  6. // sf = function that returns char* and takes char* as arg
  7. typedef char* (sf)(char *s);
  8.  
  9.  
  10. char* f1(char *s) {
  11. printf("f1: %s\n", s);
  12. }
  13.  
  14. char* f2(char *s) {
  15. printf("f2: %s\n", s);
  16. }
  17.  
  18. main(int argc, char *argv) {
  19.  
  20. sfp sfp1, sfp2;
  21. sf *sf1, *sf2;
  22.  
  23. sfp1 = f1;
  24. sfp2 = f2;
  25.  
  26. sfp1("alice");
  27. sfp2("bob");
  28.  
  29. sf1 = f1;
  30. sf2 = f2;
  31.  
  32. sf1("charlie");
  33. sf2("david");
  34.  
  35.  
  36. }
Add Comment
Please, Sign In to add comment