Okay.
Welcome back guys.
We're gonna create a Hello World program now but just just be a simple program written and see that
outputs the message Hello world.
Very very simple.
So let's open up visual code that you installed.
Make sure you don't accidentally press Visual Studio.
If that's what you have a visual studio code is what the one we should be opening.
I know you'll see that you'll see that it's all nice and open.
And we're going to create a new folder on our desktop.
So open up your browser here your file browser.
We're just gonna call it hello world.
Hello world.
Make sure there's no spaces.
Right.
Cool.
So in here back in visual code.
Go open folder.
File Open folder.
Select your desktop Hello World app.
And I should load it.
Excellent.
So you'll see this new file button by here.
Hello World app new file just click it and we're going to call it main dot see.
OK.
And then it's gonna ask you down here we recommend you install this extension press install because
that all that that'll actually help us when writing our C code and if it didn't give you that by the
way just click the little plug ins thing down here the extensions and just search for C C or C++ as
you install something to help you a little bit more.
So that is now done that.
So what I want you to do is is I want you to include a -- and -- in C basically files
that contain loads of definitions and function prototypes but more on that later.
Just copy what I'm doing.
So we're gonna go hash tag include and then we're going to go CDI o dot Hage.
So it should look like that include left arrow CDI o da Hage right arrow.
So that'll give us access to some printing functions some functions that allow us to print messages
out to the users no actually print on your home printer.
Our message to the user basically contains a lot of you a lot of functions that allow us to handle user
output and input and and so on.
So what I want you to do now is go integer main bracket instead Argosy char ugly.
I'm actually copying me exactly guys.
So yeah you can see there's a there's a comma there as well.
Don't forget anything.
So I'm briefly going to go over this now but you will know more about it later on as we go through the
tutorial.
So um as I explained to the IO dot Haiti's a file that contains prototypes two functions that we can
use to output messages to the user said.
That's a bit of a mouthful.
You don't have to worry we'll explain them much more later on.
So this is a function called Main and the main function is basically executed whenever you start your
program.
So anything in between anything by here will be run when you when you run your program basically.
Now this function contains two arguments c an odd V.
Now using these two together can allow us to access data that the user can pass to us when when loading
our program.
So that briefly explains that.
But you don't need to worry too much about that yet because this is the very first tutorial.
So what are you doing in between these brackets.
I just wanted to return 0.
Now what this is going to do is this function will get run and then we just return to zero Back to the
operating system because the operating system calls this function for us.
Right.
If you return anything other than zero.
Anything other than zero it is classed as an error.
Only if you're returning it from the main function though right.
What'll happen is on the command prompt or terminal if you're in Linux it'll tell you code returned
and it will be what you returned here.
So.
So this allows you to return states to the back to the calling program the program that's running you.
So returning zero generally means everything went okay.
Returning some negative is usually error.
But you know even returning something positive can be an error but usually it's a negative value if
there's a problem.
Anyway back to the story.
So once you've done return to zero that means that we're basically saying Yeah everything grand and
fine.
It's just something we're returning to the call.
But we need to output.
Hello world.
So go go into here and type.
Print f hello world explanation.
And put a semicolon at the end here.
So you should see this is your program now and it's very simple.
Outputs.
Hello World and then returns.
Now if you didn't have this the program would still compile but a return whatever was on the stack at
that time which you can basically assume that it's undefined behavior so you shouldn't should always
return something when the type is not.
Avoid type but we'll we'll explain more about what void is an integer later on.
That's just something to remember in case you know a little bit about that already.
Now go back to your file explorer and go to your directory go to the directory that you created your
app on lines on the desktop and all I want to do I want you to copy the euro up here and we're gonna
go here.
When I type.
Command prompt.
I want you to see these.
I just want you to right click in a ship pasted in automatically and just press enter.
And while I was without change the working directory to to the hello world app and now we're gonna go
GCSE dot forward slash main dot c space dash o dot forward slash Main and just press enter.
And now you can see if you go back to the directory is curated a file called Main XY.
So we've basically now just compile our program so GC C is the compiler we pass in our input file which
is made out C and then we use dash o to say that we're about to output the compiled file.
This is where we wanted output to and we used top forward slash main and forward slash main is our output
file so it takes maned up C which is our program we just wrote here it compiles it into machine code
and symbols and dynamic basically object files and then it creates an executable called Main and on
on Linux you will actually see main but on Windows it appends the dot XY at the end.
The compiler does so if we know to dot forward slash main dot XY by the way dot forward slash means
this directory in case you didn't know.
So when we do dot forward slash it means it means in this case it means inside the hello world app directory.
Anyways so due to a forward session I mean the EMC and press enter and you see a complaint so let's
give it a.
That's just your main dot XY and it will say hello world.
So congratulations you've just written your very first C program.
I'm sure you're pretty confused right now especially with some of the terms I've been talking about
but you really not need to worry because this is our very first lecture and was designed to just give
you a taste of the pudding essentially.
So all of this will be explained in further in depth will explain what these these types are.
We'll explain how the Craig functions will explain what these two asterisks mean you know things like
that which are probably confusing you right now.
So there's really nothing to worry about.
Keep following the course and all will be revealed.
So yeah.
Congratulations on creating your very first C program.
Good job.