Installed and ready to start following along with this course and writing some awesome C programs in this tutorial I’m gonna talk to you guys about getting our first C file setup so we’re gonna load up.
A C file and we’re gonna be able to get everything working and test out our program so I’m gonna open up my codeblocks program and this is the IDE that I’m gonna be using for the rest of this course so I’m just gonna double click on it and it should start opening once we have codeblocks open you’ll see over here there’s a bunch of different options like create a new project open an existing project so we’re actually going to want to create a new project so whenever.
We’re gonna start writing some C files we’re gonna want to create a new project in code blocks so you can either click this button right here or you can go up to file new and projects so either way it’s gonna.
Bring you to this window over here and there’s gonna be a bunch of.
Options here basically just these are.
Different types of like C projects that we could create what we’re gonna be doing is creating a console application this is like there’s a basic C project that you can run on your computer that’s exactly what we need so click on console application and then click go and I’m just gonna click through this wizard and you’ll see over here it says C++ or C now C and C++ are both different programming languages for this.
Course we’re gonna be working with C so just highlight C and click Next and we’re gonna give this a title I’m just gonna call mine draft and we’re gonna have to put this project inside of a folder so I’m gonna open this up and I’m just gonna put this on my desktop so let’s click.
Can leave all of these options.
As the default and we’ll click finish so now what we should have is our first.
C project in code blocks now over here inside this little File Explorer you’ll notice that draf is right here so that.
Was the name of the project that I just created down here we have this source folder so I’m going to click down and you’ll see we have this file here called main dot C and this is a file.
That got automatically created for us by code blocks I’m just gonna right click and open it and you’ll see over here.
We have some default code so up here there’s these little lines of code that say include down here this says int main so this is the program that we’re given by default.
When we created our C project and this is sort of like the simplest C program that you can right essentially what this program does is it prints out hello.
World onto the screen so in order to run this program and test it just to make sure that everything’s working I’m gonna come up here and you’ll see that there’s this green play button over here and it just says run when I hover over it when I click this.
Button this file that we have open right here main see is gonna get run so we’re essentially telling code blocks to run this file and execute the program so when I.
Click the Run button we’re getting this message it says the project hasn’t been built yet do you want to build it like yes and now over here this little window pops up basically this is the command prompt so whenever I run a C program this little window is gonna pop.
Up so if I was to exit out of this and run this program again you’ll see this window pops up again and it basically just executes the program and in the case of.
This program all we’re doing is we’re printing out hello world onto the screen and that’s actually what this instruction does over here when we open up this command prompt it’s essentially just executing the program and it’s printing out whatever we told it to print out so it’s printing out hello.
Printing something out onto the screen is really easy and that’s one instruction that we can give to the computer but as we go.
Through this course we’re going to learn all sorts of instructions that we can use but the purpose of this tutorial was just to get our C project set up and to test our main dot C file so.
As long as everything works here and you’re good to go and now we can start really learning how to program in C in this tutorial I’m going to talk to you guys about the basics of writing a program in C so if you’ve been following.
Along with the course up to this point we’ve installed a text editor.
We’ve installed a C compiler and we set up our first C program and our first C project inside of code blocks so now essentially what we have is this file over here this is that.
Main dot C file I just kind of want to point out a couple things that are in here first up here we have these little instructions which are just called include and I’m not gonna get too much into what those do in this tutorial later on in the course we’re gonna talk about what these are actually doing and the specifics.
Of you know how they’re helping our program but for now just know that in order for us to use our program we’re gonna need to have these guys up there next thing we have is.
This little block of code called main and it just has this name main you can see there’s an open and closed parenthesis and this is actually what’s called a method and.
Don’t worry too much about what methods are we’re gonna again we’re gonna talk more about those in future but essentially a.
Method is just like a container where we can put some of our code and this method main is very important because this is the method that’s going to get executed when we run our program so in C we can actually.
Write out a bunch of instructions for the computer and then we can run our program so we can tell the computer to execute.
Those programs and whenever the computer executes our C program it’s gonna look inside of this.
Main method in other words that’s gonna look.
Inside of all the code inside of these open and close curly brackets and it’s gonna execute that code so I have this instruction here it’s called printf and basically this is just printing out some text onto the screen when we run our program it’s gonna come into this main method and it’s gonna execute all.
The instructions inside of here namely this printf method so if I was to run my program then this is gonna work now let’s talk.