fork(1) download
  1. /*
  2.  * Test of code for http://stackoverflow.com/questions/15922878/pointer-to-a-nested-structure.
  3. */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7.  
  8. struct one
  9. {
  10. struct two
  11. {
  12. int r;
  13. }*b;
  14. }*a;
  15.  
  16. int main()
  17. {
  18. a = malloc(sizeof *a);
  19. if(a != NULL)
  20. {
  21. a->b = malloc(sizeof *a->b);
  22. if(a->b != NULL)
  23. {
  24. a->b->r = 10;
  25. printf("the value is %d\n", a->b->r);
  26. }
  27. }
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 1920KB
stdin
Standard input is empty
stdout
the value is 10