fork download
  1. #include <stdio.h>
  2. #include <stdint.h>
  3.  
  4. void func(void) {
  5. printf("Hello!\n");
  6. }
  7.  
  8. int main(void) {
  9. uint32_t* interim = (uint32_t*) &func;
  10.  
  11. void(*ptr1)(void);
  12. ptr1 = (void*) interim;
  13. ptr1();
  14.  
  15. void(*ptr2)(void);
  16. ptr2 = (void(*)(void)) interim;
  17. ptr2();
  18.  
  19. printf("The function pointers store ");
  20. printf(((ptr1 == ptr2) && (ptr1 == &func) && (ptr2 == &func)) ? "identical" : "distinct");
  21. printf(" addresses.\n");
  22. }
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
Hello!
Hello!
The function pointers store identical addresses.