My first C program in ubuntu 8.10 (linux).


after installing ubuntu 8.10 on pendrive as start up disk i decided to write a simple c program in ubuntu.as you might have guessed its the helloworld program.the output of the program prints a hello world on the console.

step 1: click on applications>>accessories>>text editor.  text editor window pops up.

step 2:write your simple c program you wish to run.or else copy from here.

#include

int main(void)
{
printf(“hello world\n”);
return 0;
}

step 3: save the file as filename.c with .c extension as shown and open the terminal.(click on applications>>accessories>>terminal)

step 4:type “gcc filename.c -o filename” without the quotes on the terminal

step 5.type  “./filename” .you should be seeing the output on next line.

what went wrong:

1) make sure that you are in the same directory(terminal) where file exists.for example if the file is on desktop, change directory to desktop by using cd command.

cd Desktop

make note that uppercase D is used for “Desktop” and not lowercase

2) install the basic compiler functionalites by typing the following command on the terminal if its not already installed.

sudo aptitude install build-essential

This entry was posted in Uncategorized and tagged . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>