Added: inherit

This commit is contained in:
Logen Kain 2017-01-25 20:14:19 -07:00
parent c2e5bdbf05
commit 74fa6bea32
3 changed files with 55 additions and 0 deletions

1
inherit/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
inherit

22
inherit/Makefile Normal file
View File

@ -0,0 +1,22 @@
#OBJS specifies which files to compile as part of the project
OBJS = main.c
#CC specifies which compiler to use
CC = clang
#COMPILER_FLAGS specifies the additional compilation options we're using
# -w suppress all warnings
COMPILER_FLAGS = -Wall
#LINKER_FLAGS specifies the libraries we're linking against
LINKER_FLAGS =
#OBJ_NAME specifies the name of our executable
OBJ_NAME= inherit
#This is the target that compiles our executable
all : $(OBJS)
$(CC) $(OBJS) $(COMPILER_FLAGS) $(LINKER_FLAGS) -o $(OBJ_NAME)
clean :
rm struct

32
inherit/main.c Normal file
View File

@ -0,0 +1,32 @@
#include <stdio.h>
#include <string.h>
int main ()
{
typedef struct
{
int life;
int magic;
}Vehicle;
typedef struct
{
Vehicle vehicle;
char brand[10];
}Car;
Car ford;
ford.vehicle.life = 5;
ford.vehicle.magic = 9;
strcpy(ford.brand, "Ford");
printf("The car's life is: %d\n" "The car's magic is: %d\n"
"The car's brand is: %s\n", ford.vehicle.life, ford.vehicle.magic,
ford.brand);
//code
}