practice/inherit/main.c

34 lines
449 B
C
Raw Normal View History

2017-01-25 20:14:19 -07:00
#include <stdio.h>
#include <string.h>
int main ()
2017-01-25 20:14:19 -07:00
{
typedef struct
{
int life;
int magic;
}Vehicle;
typedef struct
{
Vehicle vehicle;
char brand[10];
}Car;
Car myCar;
myCar.vehicle.life = 5;
myCar.vehicle.magic = 9;
strcpy(myCar.brand, "Dodge");
2017-01-25 20:14:19 -07:00
printf("The car's life is: %d\n" "The car's magic is: %d\n"
"The car's brand is: %s\n", myCar.vehicle.life, myCar.vehicle.magic,
myCar.brand);
2017-01-25 20:14:19 -07:00
}