C Programming Tutorial 3 – Writing Our First Program – Hello World

In this video we are going to write our first computer program. If you are new to programming, you should know what a Hello World program is. Essentially, a hello world program is a program that says “Hello World” on the screen.
 
The point of this is to have the confidence that you have all of the proper tools installed, everything is set up correctly, you’re able to write the most basic program, compile it, and execute it. Essentially, a Hello World program will take you from beginning to the end of writing a program.
 
The very first thing we have to do is create the file that we are going to write all of our code in.
 
vim hello.c
 
the .c at the end of the file is called a file extension. The C means that it is a C file. Make sure you end all of your C files with .c.
 
Now once we have the editor open, we want to start typing. VIM has different modes, so we actually have to switch to Insert mode. Press i.
 
Now, you can start typing. To get out of insert mode we can press the Esc key.
 
Now to move your cursor around in your program, you can use your arrow keys. Later on we’ll learn some more fancy tricks to navigate, but this is a great way to adjust to using VIM as it’s very similar to any other text editor. Just don’t tell anybody I told you that.
 
Let’s go back into insert mode.
 
Now basically everything I type in this video may be new to you. That is ok!! In the next video I will go over what everything means and by the end of this series this will be a piece of cake.
 
Once your program is done you can exit vim by typing :wq while not in insert mode. This will write your changes to disk and then quit.
 
now, we need to compile:
 
gcc hello.c
 
Now, let’s take a look at the folder we are in by typing ls
 
You can see that we have hello.c, and a.out. a.out is the executable that gcc created. We can now run this to see it in action. To run the program type:
 
./a.out
 
The ./ is to say that we want to execute something in the current location, and then the name is all we need to run the program.
 
There you go! Congratulations!
 
Now, if you’re not so lucky, you’ll have some problems with your code and the program will refuse to execute.

Always try again! Just remember…if at first you don’t succeed, don’t try sky diving!
Let’s see what that looks like by changing some of our code.
 
Now, when we run gcc, we get errors pop up. A lot of this can look like gibberish sometimes, but read it closely. Often it will give you a hint as to where and what is wrong.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Support me! http://www.patreon.com/calebcurry

Subscribe to my newsletter: http://eepurl.com/-8qtH

Donate!: http://bit.ly/DonateCTVM2.

~~~~~~~~~~~~~~~Additional Links~~~~~~~~~~~~~~~

More content: http://CalebCurry.com
Facebook: http://www.facebook.com/CalebTheVideoMaker
Google+: https://plus.google.com/+CalebTheVideoMaker2
Twitter: http://twitter.com/calebCurry

Amazing Web Hosting – https://www.dreamhost.com/r.cgi?1487063 (The best web hosting for a cheap price!)

Comments

Tom Jerry says:

When I compile a bunch of source code files from Github, gcc told me “missing config.h”, WTF is that?

IndieTeenGamer says:

WHY DONT PEOPLE WATCH YOUR VIDEOS!?!??!!

DarkSoldier says:

cool video, good work , , greetings from Ecuador

Anam Navied says:

So after you complied your C source file, you typed ./a.out to run it. If I had multiple C files and I wanted to run one would I have to do gcc NameOfThatFile.c first and then ./a.out each time I wanted to run the file (even though I had compiled it earlier)? That seems redundant to me

Naftali Mbuto says:

hey Caleb I like your videos
but this third video is. abit tricky

Josh R says:

Great videos! Helped me a lot so far in my very frustrating class of CS 3100 Operating systems.

Julio Oliveira says:

Your video popped up on my feed. Seems it’s a nice playlist for beginners. You might explain later but jumping from compiling with gcc to running the output might make people confused. You could have listed the content of the directory (sorry, you are on mac, folder) and explained that if you dont specify the output name cgg will outomatically name the output that.

Nunya Dambidnis says:

glad to see you back at it

Youtubehomie says:

thats basically like making a.txt file saying hello then going to the terminal and typing cat hello.txt

Write a comment

*

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles▷ Show Cars▷ Motorbikes▷ Scooters▷ Bicycles▷ Rims & Tires▷ Luxury BoatsFashion▷ Sunglasses▷ Luxury Watches▷ Luxury Purses▷ Jeans Wear▷ High Heels▷ Kinis Swimwear▷ Perfumes▷ Jewellery▷ Cosmetics▷ Shaving Helpers▷ Fashion HatsFooding▷ Chef Club▷ Fooding Helpers▷ Coktails & LiquorsSports▷ Sport Shoes▷ Fitness & Detox▷ Golf Gear▷ Racquets▷ Hiking & Trek Gear▷ Diving Equipment▷ Ski Gear▷ Snowboards▷ Surf Boards▷ Rollers & SkatesEntertainment▷ DIY Guides▷ Zik Instruments▷ Published Books▷ Music Albums▷ Cine Movies▷ Trading Helpers▷ Make Money▷ Fishing Equipment▷ Paintball Supplies▷ Trading Card Games▷ Telescopes▷ Knives▷ VapesHigh Tech▷ Flat Screens▷ Tech Devices▷ Camera Lenses▷ Audio HiFi▷ Printers▷ USB Devices▷ PC Hardware▷ Network Gear▷ Cloud Servers▷ Software Helpers▷ Programmer Helpers▷ Mobile Apps▷ Hearing AidsHome▷ Home Furniture▷ Home Appliances▷ Tools Workshop▷ Beddings▷ Floor Layings▷ Barbecues▷ Aquarium Gear▷ Safe Boxes▷ Office Supplies▷ Security Locks▷ Cleaning ProductsKids▷ Baby Strollers▷ Child Car Seats▷ Remote ControlledTravel▷ Luggages & Bags▷ Airlines Seats▷ Hotel Rooms▷ Fun Trips▷ Cruise Ships▷ Mexico Tours