- In this video,
we will discuss a new concept in the C programming language,
Structures.
Let's see what they are.
Structures are an entity
that allows us to combine multiple types of variables
into a single one.
For example, chars, integers, and floats.
We can define a complex type beyond the standard built ones.
For example, we may want to have a vector
that has three floats
designating its three dimensions: x, y, z.
And, we can create those complex variables
and manipulate them as if they were just one variable.
Let's see how this looks in C.
This program shows a very simple definition of a struct
using three variables that are packed into a struct
in line 23 called book.
A book is typically associated with a title, an author,
and a publisher,
but we want to refer the book as one entity.
Therefore, we are going to define three arrays.
One for title name, one for author, and one for publisher.
Those are arrays of characters also known
sometimes as strings.
In order for be as generic as possible,
I defined three admissible maximum length.
One for title, one for author, and one for publisher
in line 14, 15, and 16, respectively.
I have now created a new type called book,
which for all intense and purposes,
it's now added to my list of available types
including those built in.
So, now I have int, float, double, and book.
We will see in the upcoming videos,
how we can put that to use.