Skip to content

Instantly share code, notes, and snippets.

@pkrll
Created May 26, 2019 12:02
Show Gist options
  • Save pkrll/1648b2ecd8f802dfd7974d3df60f9ac9 to your computer and use it in GitHub Desktop.
Save pkrll/1648b2ecd8f802dfd7974d3df60f9ac9 to your computer and use it in GitHub Desktop.
Question 1
#include <stdlib.h>
struct bar {
char *g;
};
struct foo {
struct bar *f;
int *y;
int *z;
};
int main() {
//!showGraph()
int z;
struct foo *x = malloc(sizeof(struct foo));
x->f = malloc(sizeof(struct bar));
x->y = malloc(sizeof(int));
x->f->g = "Hello World!";
*x->y = 42;
z = *x->y;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment