Main Menu

friends

Banner

Latest articles

The Budget Traveller's Guide to Sleeping in Airports
20/04/2010 | mad mad mod

The Budget Traveller's Guide to Sleeping in Airports:  www.sleepinginairports.net  "For travellers who are REALLY on a budget and are looking for a way to skim a few bucks off their travel e [ ... ]


How to fake the mac address on Linux
29/12/2009 | mad mad mod

Step 1. shutdown the interface (e.g. eth0)

# ifconfig eth0 down



Step 2: change the mac address to e.g. 11:22:33:44:55:66

# ifconfig eth0 hw ether 11:22:33:44:55:66



Step 3. restart the interface

# ifconfi [ ... ]


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