editing the source code

Unix has at least four different text editors. The
most convenient one is emacs.
Emacs is extremely powerful, it has nice features like

syntax highlighting,

auto-indentation,

debugging support

which help programming a lot. If you don't know emacs yet,
it might be a good idea to learn it. Emacs has a built in
tutorial. Experienced users spend
most of their time in emacs (even for email, unix shell commands, etc.)

Alternative editors are vi, which takes
some time getting used to, and textedit -
a very simple editor. The editor pico might
be a good choice for people new to unix, it's very similar to the editing
mode of the email program pine.

You can start emacs as follows:

log onto your unix account

type emacs followed by return.
this is the unix way to start programs. Your command line
should look similar to mine:

(courses2){biermann}[41]% emacs

when the emacs window pops up, select the tutorial from the
help menue

compiling and running your program

You should try out one of the example programs, let's say the
hello-world program. Here's a step by step explanation of how
to compile the program:

type the program (or copy it from the web) and save it as
"hello.c". I'm using emacs to enter the program:

(courses2){biermann}[43]% emacs hello.c

call the compiler from an unix shell - if you're not sure how
to do this, just quit your editor and write:

(courses2){biermann}[44]% gcc hello.c

the compiler is generating an executable with the default
name "a.out". Your shell dialogue should look like:

some more details

Actually, gcc does multiple steps to create an executable from your
source code. At first, your program was compiled into object code, then
your code is linked to the libraries in order to create an executable.
You can control these these steps separately:

We can compile the source code without actually linking it, using
the -c options of the compiler. Gcc is generating a file called
"hello.o" for the object code:

(courses2){biermann}[56]% gcc -c hello.c

In order to link the code, we're just calling gcc with the object
file(s) to link. Also, we're providing a name for the executable
with the compiler option -o:

(courses2){biermann}[57]% gcc hello.o -o hello

We can start our program "hello" by typing it's name in the command
line. You can also set up your path in such a way, that you don't
need to type the beginning "./"