Zone's C Programming Tutorials #1 Printf function

ZoneAye

Known Member
Messages
12
Reaction score
5
Points
118
Hi everyone this is my first C Programming tutorial before we start i would like to say that if you have no programming knowledge then C is probably not the best choice for your first language i would recommend something easier like C# or vb.net but you can stick with C if you want :grinning:

Before we start you must have the following
any ide that you are able to develop C programs in can be Visual Studio, code blocks or Dev ++
A functional brain
spare time

IDE stands for Integrated Development Environment just so you know its basically software that allows you to program in.

You will NOT learn C in a matter of minutes,hours or weeks to learn it fully it can take months usually between 4 - 6 and can even if you do a lot of studying and are a quick learner. It can aslo take years to learn.

Anyway lets began in this Tutorial i will show you how to use the Printf function it is used to output characters to the console i will have examples below :grinning:

Step 1: Creating a program

So after you have installed your choice of software you want to create a console application. I will be using vs 2015 so if you have that follow what i do :grinning:

Click New Project
then you will get a pop up
Name your program and where it says Location choose where you want the output to be :grinning:
If you are using any vs apart from 2010 you will have to un tick Security Development Lifecycle (SDL) checks if you don't your program may mess up.


step 2: creating your first program
so when you do that and load your program up you should get a bit of code named

int main()
{

return 0;
}

This is called a block of code or a function every thing you do in a C program must be linked to this function in some way you can just ignore the #include "stdafx.h" that's just apart of the C library so the compiler actually knows you are using C.

so all we are going to out put to the console is the words "Hello World". To do this we use the printf function. I i Will now show you how to do this.

int main()
{
printf("Hello World");

getchar();

}

As you can see i do not have return 0; as we do not need it in this program.

printf is just printing the words "Hello world" to the console
getchar is waiting for the user to enter a key to close the console.

Try and see what happens if you don't use getchar();

blow are just some different ways of outputting stuff :grinning:

\n = new line
\t = tab
\a = audio

I would recommend testing all of these.

So guys that is my first C Programming Tutorial hope you have enjoyed reading if anyone needs help just pm me :grinning:

Next Tutorial will be on varibales :smile:

> Zone
 
Last edited:
Top