The installation in the Linux lab is already set up for
compiling C programs either from the command line or from
Eclipse (which I recommend).
If you're using another type of computer, see the bottom of this
Eclipse is a powerful program written for developing programs of
all types. It was originally developed for writing Java programs,
but it handles C (and C++) nicely if you include a very nice standard
extension called CDT.
First, you need to create your project. Under the File
menu's New submenu, select Project. In the first panel, select
“C Project” (under C/C++).
Enter a name in the next panel, and in the subsequent panels
just accept the defaults before finally getting to select Finish.
(Important: choose a project name that does not include
any space characters — this has been known to cause
Eclipse will prompt you about changing the perspective. You
want to do this.
Now create your program by creating a new Source File
(using the File menu's New submenu).
For the “Source Folder” field, click “Browse…”,
select your project name, and then click OK.
For the “Source File” field, type the name of a file
ending in “.c”, such as count.c. You can now edit
Save your file before attempting to compile or execute it.
When compiling the file, Eclipse works with what is saved on disk,
not what appears on the screen.
Once you have edited this file to contain the code you
want to execute, you will need to build the project. In the
Project menu, select Build All (or press control-B). If any errors result, Eclipse
will flag them at this point. (In contrast to how it handles Java programs,
Eclipse won't notice the errors until you build the project.)
To execute the program, go to the Run menu and select Run (or press
You only have to use the menubar once.
After that, the green Play button in the toolbar will
repeat whatever you last ran. For that matter, the hammer button
in the toolbar will build the project a second time.