Ruan Bekker's Blog

From a Curious mind to Posts on Github

Simple Program With C Language on Linux

Today the idea popped up on how to write a Simple “Hello World” Application using C Programming Language, as I just wanted to see how it works.

Requirements:

You will need the gcc package to compile the program:

RHEL
1
$ yum install gcc -y
Debian
1
$ apt install gcc -y

Writing our first Program:

We will create a app that just prints out a static defined value:

Create any file with a .c extension, in my case it will be app.c:

app.c
1
2
3
4
5
6
#include <stdio.h>

int main(){
    printf("Hello, World\n");
    return 0;
}

Now compile app.c with gcc and specify the output path of your app with -o <app-name>

app.c
1
$ gcc -o app app.c

Testing our App:

You will see that there is a executable file with the name that you have specified as the output:

app.c
1
2
$ ./app
Hello, World

Really basic, but quite cool.

Comments