Created
December 29, 2014 15:41
-
-
Save rmarianski/89b11618bd0aa8220073 to your computer and use it in GitHub Desktop.
Embed structures in c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
typedef struct point { | |
int x, y; | |
} point; | |
typedef struct point3d { | |
struct point; | |
int z; | |
} point3d; | |
int main() { | |
point p1 = {.x=1, .y=2}; | |
point3d p2 = {.x=1, .y=2, .z=3}; | |
printf("%d,%d\n", p1.x, p1.y); | |
printf("%d,%d,%d\n", p2.x, p2.y, p2.z); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment