47 lines
944 B
C
47 lines
944 B
C
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
int main ()
|
|
|
|
|
|
|
|
{
|
|
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");
|
|
|
|
printf("My car's life is: %d\n" "My car's magic is: %d\n"
|
|
"My car's brand is: %s\n\n", myCar.vehicle.life, myCar.vehicle.magic,
|
|
myCar.brand);
|
|
Car herCar;
|
|
herCar.vehicle.life = 8;
|
|
herCar.vehicle.magic = 5;
|
|
strcpy(herCar.brand, "Saturn");
|
|
|
|
printf("Her car's life is: %d\n" "Her car's magic is: %d\n"
|
|
"Her car's brand is: %s\n\n", herCar.vehicle.life, herCar.vehicle.magic,
|
|
herCar.brand);
|
|
|
|
Car herCar2 = herCar;
|
|
|
|
|
|
|
|
printf("Copy of HerCar\n" "Her car's life is: %d\n" "Her car's magic is: %d\n"
|
|
"Her car's brand is: %s\n", herCar2.vehicle.life, herCar2.vehicle.magic,
|
|
herCar2.brand);
|
|
|
|
}
|