Main Menu

friends

Banner

Latest articles

setting up a very simple firewall (Fedora)
03/08/2009 | mad mad mod

This article describes how to set up a very simple desktop-firewall on Linux (Fedora).  Step 1: make sure iptables is installed on your system:# rpm -qa | grep iptables
iptables-1.4.1.1-1.fc8&nbs [ ... ]


monitor I/O with iotop
11/03/2010 | mad mad mod

iotop is a nice tool to monitor I/O usage information output by the Linux kernel (requires 2.6.20 or later). To install iotop with yum as root (for RedHat / Fedora / Centos based systems only)&nb [ ... ]


Other Articles
Facebook MySpace Twitter Digg Delicious Stumbleupon Google Bookmarks 

Designed by:
SiteGround web hosting Joomla Templates
Hello World in C E-mail
programming

This article describes how to write, compile and execute a "Hello World" program in C on Linux (Fedora).

 

1. the prerequisites

  • a text editor of your choice (e.g. vi)
  • a C compiler (e.g. gcc)


make sure you have installed the GNU C compiler rpm:

# rpm -qa gcc
gcc-4.1.2-33

 

If it is not installed yet, you can install it with yum (you need to be root to do that):

# yum install gcc

 

 

 

2. write the code


open an empty file with a text editor (e.g. vi):


# vi helloworld.c


now write the following code into the sourcefile:


#include <stdio.h>

int main ()
{
printf ("Hello World!\n");
}


save the file and exit vi with ":wq + enter"

explanation


#include <stdio.h>

This loads some definitions for basic I/O functions (used for the command "printf").

 


int main ()
{
 (...)
}

The main function ist where the execution of the program starts.

 


printf ("Hello World!\n");

This prints out the string "Hello World!" and a "line break" (\n).

 

 

 

3. compile the code



# gcc helloworld.c -o helloworld




This produces an executable called "helloworld".



4. run the program


you can now execute the binary program with:


# ./helloworld
Hello World!

 

 

 

Comments (0)
Write comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
:D:angry::angry-red::evil::idea::love::x:no-comments::ooo::pirate::?::(
:sleep::););)):0
Security
Please input the anti-spam code that you can read in the image.

!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved."

 
mad mad mod, Powered by Joomla! and designed by SiteGround web hosting