Final working code, reference for some other people:
Code:
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
struct thing {
int x;
char *y;
};
void f4(struct thing *bob) {
bob->x = 4;
strcpy(bob->y, "4");
printf("4: %d, %s\n", bob->x, bob->y);
}
void f3(struct thing *bob) {
bob->x = 3;
strcpy(bob->y, "3");
printf("3A: %d, %s\n", bob->x, bob->y);
f4(bob);
printf("3B: %d, %s\n", bob->x, bob->y);
}
void f2(struct thing *bob) {
bob->x = 2;
strcpy(bob->y, "2");
printf("2A: %d, %s\n", bob->x, bob->y);
f3(bob);
printf("2B: %d, %s\n", bob->x, bob->y);
}
void f1(struct thing *bob) {
bob->x = 1;
strcpy(bob->y, "1");
printf("1A: %d, %s\n", bob->x, bob->y);
f2(bob);
printf("1B: %d, %s\n", bob->x, bob->y);
}
int main(void) {
struct thing foo;
foo.y = malloc(100);
foo.x = 0;
strcpy(foo.y, "0");
printf("0A: %d, %s\n", foo.x, foo.y);
f1(&foo);
printf("0B: %d, %s\n", foo.x, foo.y);
free(foo.y);
return 0;
}