fork download
  1. #include <stdio.h>
  2. #include <stdlib.h> // required for malloc
  3.  
  4. int* func2()
  5. {
  6. int *x = (int *) malloc(sizeof(int));
  7. printf("in func2\n");
  8. *x = 50;
  9. return x;
  10. }
  11.  
  12. void func1()
  13. {
  14. int *y;
  15. printf("in func1\n");
  16. y = func2();
  17. if (y != 0) {
  18. printf("*y = %d\n", *y);
  19. }
  20. free(y);
  21. }
  22.  
  23. int main()
  24. {
  25. func1();
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 5296KB
stdin
Standard input is empty
stdout
in func1
in func2
*y = 50