Friday, September 28, 2007

Working with the GNU's GCC compiler collection in GNU/Linux

The GNU's GCC compiler collection is a bit different from various other compilers that people generally know; the most common one being the Turbo C++ compiler for Windows.

The basic C-program in Turbo C++ 3.0 (blue screen appication) is written as follows:
----------------------------------------------------------------------------
#include"stdio.h" //in the entire post i am using (") instead on (< >)
#include"conio.h"

void main()
{
printf("Hello World");
}
-----------------------------------------------------------------------------
the code is written and then compiled and executed using keys like (Alt+F9) and (Ctrl+F9).


the same code can be written in GNU/Linux:
the steps are:

1.goto desktop and create a file and write this code which prints "Hello World"
-------------------------------------------------------------------------------
#include"stdio.h"
//#include"conio.h" -- this header file doesnt exist in GCC
int main(void)
{
printf("Hello World");
}
-------------------------------------------------------------------------------
2.Save this file as hello.c
3.open the terminal
4.goto the Desktop folder
5.type "gcc hello.c -o hello"
6.then type "./hello"--this gives the output.

No comments: