all right guys welcome back and in this
video I'm going to be talking to you
guys about these lines at the very top
of your program and they're technically
called preprocessor
directives now you know how I told you
guys like in the first video that the
reason that we download this piece of
software is not only so we can type code
in it but also one of the jobs of this
piece of software was basically a take
code that we can understand of course we
can read this this is the word include
domain and it pretty much translates it
into ones and zeros or in other words
code the computer can understand now
this process the technical term for it
is compiling your program so what these
lines are and why I even mentioned that
is because before your program compiles
what it does is it
includes or pretty much runs your
pre-processor processor directives kind
of a tongue twister but basically it's
going to grab the entire file wherever
you tell it to so it's going to grab
stdio.h and stdlib.h and it's going to
substitute them in place right here now
after all your pre-processor directives
are finished completing then it's going
to go ahead and compile your program and
also um like this one right here this
stdi iio stands for standard input
output and and that's what allows us to
use that print F because it outputs
stuff on the screen so again what this
include does is basically include
another file with well whatever um we
want to put in it and I'll actually show
you guys how to make your own file in
just a second now another pre-processor
directive you can use other than include
is actually one called Define and I'll
show you guys how to use that right now
pretty much type in the I call it
hashtag cuz I'm stupid Twitter now but
the pound sign hit Define and what a
constant is is it's basically it's kind
of like a variable but its value can
never change so whenever you have a
variable like tuna you can set it equal
to 21 and then later on you can set it
equal to 32 well with a constant you
can't change its value you set it once
in your program and it stays that way
forever so if you want to um I don't
know just make a stupid constant just to
show you guys an examp example called my
name and also whenever you're making
constants make sure that you make them
in all uppercase letters and this is
just so you can easily distinguish a
constant from variables in your program
it's uh I don't know it's just uh like
something all programmers do so of
course type the name whatever you want
to name your constant and then after it
it's values so I'll just say my name is
tuna
mcbutter and another thing I want to
point out is that you don't need a
semicolon at the end of any
pre-processor
directive so now basically what's going
to happen is anytime we have my name in
our program might as well use
it and what are we going to put
something stupid like me name B and
we'll just
write my name right there so basically
what this pre-processed is going to do
is it's going to search your program
right here and it's going to look for
any instances of the word my name and
replace them with the string tuna
mcbutter so now if we run this it says
me name be tuna mcbutter and of course
it did all of that before your program
started compiling so now let me go ahead
and actually show you guys how to use
these in a useful kind of way so clear
this out and clear this out as
well and I want to show you guys how to
include your own customade header and we
actually use one of those constants
because why the heck not so the first
thing we need to do if we want to
include another file is well create a
new file so if you go to file new empty
file and it says do you want to edit yes
and now you pretty much just uh give it
a name I'm going to name mine
bies info and you also want to put H
it's just a header file and it's just um
I'll explain you guys about the
different types of files later on but
whenever we're including this give a a h
extension it means something special to
see so hit save and then it says okay
pretty much do you want to add it yep
and another thing I want to mention is
that whenever we named it h what it
means to see is a header files so it
creates a new folder called headers and
it organizes pretty much all your header
files for you by default which is pretty
sweet so now we have two files in our
program this first one of course is the
one main.c the main one we've been
working on the whole time and we also
have this new bies dotinfo or excuse me
bues
info. now also take note of these other
header files we include were also H so
you know in case you didn't notice that
now in this one remember what's going to
happen is any code that's in here is
pretty much be copied and substituted
right whenever we write our
pre-processed directive so we can um
write something like let's just go ahead
and Define a couple constants so
Define my name and I'll put my uh real
name this time no more that tunic butter
whatever he heck his name
is and I'll just go ahead and Define um
age 28 so now and we actually don't need
to save these because whenever we build
and run it automatically saves all your
files for you so pretty cool you can do
it the lazy way so now we have a little
bit of code in this bues info. and let's
go ahead and include it in our main
program so copy this do it the lazy
way and
also delete your entire STD lib piece of
code right now and as you can see this
header and this header are brought in
using the brackets and whenever you use
brackets it says it pretty much means uh
search the default place where headers
are but we can use double quotes and
double quotes means search in the same
um directory or the same folder is our
code and it's just a little bit faster
way to bring it in um don't really worry
about it right
now and of course type the name of your
file so again it's going to include this
one this one and then it's pretty much
going to copy this and paste it right in
here that's like pretty much what it
does actually I should probably used
that analogy earlier on and then it runs
your program so now that we have this
info brought in let's make a cool
program with it I'll show you guys how
to make a program that calculates the
age of girls I'm allowed to date so I'm
like all right am I allowed to date a
girl who's like 24 if I'm 28 well I
don't know what about a girl who's 17
probably not so you know the formula for
it is this
go ahead and make a variable called int
girls age and the formula for this is
actually um and I'm going to do some
math and I know I didn't talk to you
about the um mathematical operators of C
yet but you guys will understand this
you take the age and this is my age
which is 28 and you divide it by two of
course to divide is just uh forward
slash and I'll talk like I said talk
about that later on so now of course
this is 14 for me me and you take that
and add seven and that's the age of
girls anyone is allowed to date so go
ahead and think of your age right now
divide it by two and add seven don't
they any girls younger than that so this
should equal 21 I believe
so now let's just go ahead and add a
print statement don't need to do
anything
else so I'll just put something like um
s which would be my name like Bucky
Roberts
can date girls who
are um actually girls do this percent or
older and of course now we need to give
it those uh pretty much uh like pieces
of information it asked for and this is
what I name it age or the first one is
my
name and the second one is girls age
so let's see if this
works all right so Bucky can date girls
21 or older all right I am fine with
that got to go find me some 21y old
hottie now if anyone's listening give me
a call all right so I'll talk you guys
through this one more time real quick
just so it sticks in your brain and
you're pretty much a pro at it what we
can do is we can write our own custom
header file and any code we put in here
as our program runs it pretty much grabs
this file copies all the crap in it and
pastes it right here and then your
program compiles and in our program what
we did is we took my age divided it by
two and add seven to that value and it
gave us the girl's age that you're
allowed to date and I got 21 so I'm
going to pause this video go find some
21y old hottie and I'll see you later