fork download
  1. #include <stdio.h>
  2.  
  3. int (*func_A)(void);
  4. int (*func_B)(void);
  5. int (*func_C)(void);
  6.  
  7. int
  8. func_C_ ()
  9. {
  10. return 1;
  11. }
  12. int
  13. func_B_ ()
  14. {
  15. return 0;
  16. }
  17. int
  18. func_A_ ()
  19. {
  20. /*The code is writen to always call func_B*/
  21. return func_B();
  22. }
  23. int (*func_A)(void) = func_A_;
  24. int (*func_B)(void) = func_B_;
  25. int (*func_C)(void) = func_C_;
  26.  
  27.  
  28. int main()
  29. {
  30. int result;
  31. result = func_A ();
  32. printf("%d\n", result);
  33. //here result = 0 as expected.
  34. /*Do some magic*/
  35. func_B = func_C;
  36.  
  37. result = func_A ();
  38. printf("%d\n", result);
  39. //result should be 1
  40. }
  41.  
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
0
1