Skip to content

Instantly share code, notes, and snippets.

@zrbecker
Created March 29, 2011 01:45
Show Gist options
  • Save zrbecker/891678 to your computer and use it in GitHub Desktop.
Save zrbecker/891678 to your computer and use it in GitHub Desktop.
#include <stdio.h>
typedef struct simple_s {
int x;
int y;
} *simple_p, simple;
typedef struct fancy_s {
simple s;
int dx;
int dy;
} *fancy_p, fancy;
void print_simple(simple_p s)
{
printf("Printing Simple\n");
printf("x: %d, y: %d\n", s->x, s->y);
}
void print_fancy(fancy_p f)
{
printf("Printing Fancy\n");
printf("x: %d, y: %d\n", f->s.x, f->s.y);
printf("dx: %d, dy: %d\n", f->dx, f->dy);
}
int main()
{
fancy f = { 100, 100, 10, -7 };
print_fancy(&f);
printf("\n");
print_simple((simple_p) &f);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment