fork(1) download
  1. typedef void (*void_fptr)();
  2.  
  3. void show_a()
  4. {
  5. printf("This is show_a function\n");
  6. }
  7.  
  8. void_fptr func_gen(void_fptr func)
  9. {
  10. int a = 500;
  11. printf("fptr = %d, address of fptr = %p\n",func,&func);
  12. printf("a = %d, address of a = %p\n",a,&a);
  13. void inside_func(void) {
  14. printf("\nbegin inside_func { \n\n");
  15. printf("fptr = %d, address of fptr = %p\n",func,&func);
  16. printf("a = %d, address of a = %p\n",a,&a);
  17. printf("\n} inside_func \n");
  18. }
  19. return &inside_func;
  20. }
  21. int main()
  22. {
  23. void_fptr ptr;
  24. ptr = func_gen(&show_a);
  25. (*ptr)();
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 2052KB
stdin
Standard input is empty
stdout
fptr = 134513872, address of fptr = 0xbfce42c0
a = 500, address of a = 0xbfce42bc

begin inside_func { 

fptr = 134514264, address of fptr = 0xbfce42c0
a = 134513940, address of a = 0xbfce42bc

} inside_func