Running C Programs

Objectives

The Edit-Compile-Link-Execute Process

Developing a program in a compiled language such as C requires at least four steps:

editing/writing the program
compiling it
linking it
executing it
Editing

We write a computer program with words and symbols that are understandable to human beings. This is the editing part of the development cycle. We type the program directly into a window on the screen and save the resulting text as a separate file. This is often referred to as the source file. The custom is that the text of a C program is stored in a file with the extension .c for C programming language.

Compiling

We cannot directly execute the source file. To run on any computer system, the source file must be translated into binary numbers understandable to the computer's Central Processing Unit. This process produces an intermediate object file - with the extension .obj, the .obj stands for Object.

Linking

The first question that comes to most peoples minds is Why is linking necessary? The main reason is that many compiled languages come with library routines which can be added to your program. Theses routines are written by the manufacturer of the compiler to perform a variety of tasks, from input/output to complicated mathematical functions. In the case of C the standard input and output functions are contained in a library (stdio.h) so even the most basic program will require a library function. After linking the file extension is .exe which are executable files.

Executable files

Thus the text editor produces .c source files, which go to the compiler, which produces .obj object files, which go to the linker, which produces .exe executable file. We can then run .exe files as we can other applications, simply by typing their names at the DOS prompt or run using windows menu.