From 74fa6bea32840390436af13e81e5ba2d53977aa8 Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Wed, 25 Jan 2017 20:14:19 -0700 Subject: [PATCH] Added: inherit --- inherit/.gitignore | 1 + inherit/Makefile | 22 ++++++++++++++++++++++ inherit/main.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 inherit/.gitignore create mode 100644 inherit/Makefile create mode 100644 inherit/main.c diff --git a/inherit/.gitignore b/inherit/.gitignore new file mode 100644 index 0000000..0d2a7f8 --- /dev/null +++ b/inherit/.gitignore @@ -0,0 +1 @@ +inherit diff --git a/inherit/Makefile b/inherit/Makefile new file mode 100644 index 0000000..070b4dd --- /dev/null +++ b/inherit/Makefile @@ -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 + diff --git a/inherit/main.c b/inherit/main.c new file mode 100644 index 0000000..32b7a0f --- /dev/null +++ b/inherit/main.c @@ -0,0 +1,32 @@ +#include +#include + +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 +}