Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct mystruct {
- int n;
- };
- struct father {
- int test;
- struct mystruct M;
- struct mystruct N;
- };
- int main() {
- struct father* F = (struct father*) malloc(sizeof(struct father));
- F->test = 42;
- F->M.n = 23;
- F->N.n = 11;
- int* p = &F->M.n;
- int* q = &F->N.n;
- printf("test: %d, M.n: %d, N.n: %d\n", F->test, *p, *q);
- free(F);
- printf("test: %d, M.n: %d, N.n: %d\n", F->test, *p, *q);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment