C Programming in Linux

Hello World Programs

lets programming in linux platform..

the things that you’ll need are :

1. Editor : gedit, nano, vi, vim –> I recomended vim as your editor

2. Compiler : gcc, g++ –> we will using gcc, g++ is use for c++

3. Makefile : this the script configuration for compiling programs

4. the C files : the file that would be compiled.

write this code and save as helloworld.c

#include <stdio.h>

int main(void)
{
printf(“Hello World\n”);
return 0;
}

and now write this code and save as Makefile

# Makefile for Hello World

CC = gcc
PROGNAME = helloworld
FILE = helloworld.c

all:
$(CC) -o $(PROGNAME) $(FILE)

clean:
rm -fr helloworld *.c~

now you have both Makefile and the C file, lets compile the file

just type :

make

and then you will have helloworld executable file.

and type this to run it

./helloworld

for any question, please don’t mind to mail me..

satria.nt@gmail.com


Advertisements
C Programming in Linux

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s