Receive our weekly advanced programming tips for FREE
13.Dec.
How to write the first C program
0
| 0 votes
Autor: bookkeeper
Chapter: C

C is very powerful language, but you have to start somewhere :). Here is a very simple C program.

#include <stdio.h>

int main(int argc, char** argv)
{

 printf("Hello Programmersbook.com\n");

 return 0;
}

#include will copy the given file 1:1 on the place where it was called

We need the file stdio.h to print on the console screen

Every program starts with the main function, the operation system will call this function first

This function will return an int(a number), it also take 2 parameter, an int(a number) and char** (a array of strings), this is optional and will be covered in other tutorial

The function return 0, in this case it means success.

With the printf command we print a string in the console window.

Now we need to compile it with:

gcc -o main main.c

More will come soon!