fork download
  1. #include <stdio.h>
  2.  
  3. typedef int (*TFuncPtr)(void);
  4.  
  5. static TFuncPtr FuncPtrDetonate=NULL;
  6.  
  7. static int Detonate1(void) {
  8. printf("*********************\n");
  9. printf("****** KABOOM 1 *****\n");
  10. printf("*********************\n");
  11. return 0;
  12. }
  13.  
  14. static int Detonate2(void) {
  15. printf("**********************\n");
  16. printf("****** KABOOM 2 ******\n");
  17. printf("**********************\n");
  18. return 0;
  19. }
  20.  
  21. void SetDetonate(void) {
  22. FuncPtrDetonate = Detonate1;
  23. FuncPtrDetonate = Detonate2;
  24. printf("SetDetonate Called\n");
  25. }
  26.  
  27. int main() {
  28. #if 0
  29. SetDetonate();
  30. #endif
  31.     if (FuncPtrDetonate==NULL) {
  32.      printf("^^^^^^^^^^^^^^^^^^^^\n");
  33.      printf("^^^^^^^ NULL ^^^^^^^\n");
  34.      printf("^^^^^^^^^^^^^^^^^^^^\n");
  35.     }
  36.  
  37. return FuncPtrDetonate();
  38. }
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
^^^^^^^^^^^^^^^^^^^^
^^^^^^^ NULL ^^^^^^^
^^^^^^^^^^^^^^^^^^^^
**********************
****** KABOOM 2 ******
**********************