fork(1) download
  1. #include <stdio.h>
  2.  
  3. int function_a(int a, int b)
  4. {
  5. printf("Inside function_a: %d %d\n", a, b);
  6. return a+b;
  7. }
  8.  
  9. int function_b(int a, int b)
  10. {
  11. printf("Inside function_b: %d %d\n", a, b);
  12. return a+b;
  13. }
  14.  
  15. int function_c(int a, int b)
  16. {
  17. printf("Inside function_c: %d %d\n", a, b);
  18. return a+b;
  19. }
  20.  
  21. int function_whatever(int a, int b)
  22. {
  23. printf("Inside function_whatever: %d %d\n", a, b);
  24. return a+b;
  25. }
  26.  
  27.  
  28. int (* get_function(char c)) (int, int)
  29. {
  30. switch(c)
  31. {
  32. case 'A':
  33. return function_a;
  34. case 'B':
  35. return function_b;
  36. case 'C':
  37. return function_c;
  38. }
  39. return function_whatever;
  40. }
  41.  
  42. int main(void) {
  43. get_function('B')(3, 5);
  44. return 0;
  45. }
  46.  
Success #stdin #stdout 0s 4280KB
stdin
Standard input is empty
stdout
Inside function_b: 3 5