Guest User

Untitled

a guest
Oct 27th, 2020
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct mystruct {
  5.     int n;
  6. };
  7.  
  8. struct father {
  9.     int test;
  10.     struct mystruct M;
  11.     struct mystruct N;
  12. };
  13.  
  14. int main() {
  15.     struct father* F = (struct father*) malloc(sizeof(struct father));
  16.     F->test = 42;
  17.     F->M.n = 23;
  18.     F->N.n = 11;
  19.     int* p = &F->M.n;
  20.     int* q = &F->N.n;
  21.     printf("test: %d, M.n: %d, N.n: %d\n", F->test, *p, *q);
  22.     free(F);
  23.     printf("test: %d, M.n: %d, N.n: %d\n", F->test, *p, *q);
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment