Main Menu

friends

Banner

Latest articles

How to copy a video from a digital camcorder via FireWire to your harddisk
18/07/2009 | mad mad mod

I am using the dvgrab application to copy data from my camcorder to the computer but I think there are many other ways how you can do that.
 install the packagesmake sure you have installed the ne [ ... ]


Hello World in java
18/11/2009 | mad mad mod

This article describes how to write, compile and execute a "Hello World" program in java on Linux (Fedora).  1. the prerequisitesa text editor of your choice (e.g. vi)a java compiler (go to http: [ ... ]


Other Articles

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