Pages

Thursday 21 July 2011

Compiling a C Program



Compiling a C program depends on the compiler as well as the operating system under use. Supposing that you are using Turbo C compiler on DOS platform, the compilation of a C program stored in a file called TEST.C, would look like as shown below:

C:\>tc test.c

Here, TC is the name of Turbo C compiler. The compilation would produce an object file called TEST.OBJ, Object files, thus produced, contain the machine language translation of the C program. However, this file is yet not executable. To make it an executable program you need to LINK the object files with library files, when TEST.EXE is produced.

Most often you shall be using an IDE for program development and therefore, you do not need to compile and link the programs explicitly as shown above. Every IDE provides a user friendly set of commands to carry out the compilation and linking automatically.

We will consider how Turbo C IDE may be used to develop and compile a C program. When you start the Turbo C IDE, the IDE provides all the necessary commands that let you write, compile and link your programs. A typical Turbo C IDE is displayed here:


Clearly, the IDE is menu driven. All the commands are grouped into menus such as; File, Edit, Search, Run, Compile, Debug, Project, Options, Window, and Help. You may take your time to navigate through the menus and see what command they offer to you.
To just give you a feel, we will interact with the IDE in form of a session. Let us create a program file called TEST.C containing the following program:
#include
main ()
{
printf("this is the first C program");
}
Never mind if you do not understand what this program means. It is just to demonstrate how you would write your programs and compile them.
To write the program into Test.C file:
1. Go to file menu.
2. Click at New command. Turbo C IDE opens a blank file for you, is shown here:



Note that Turbo C names the file as NONAMEOO.C. You can now enter your program in this file and save it with whatever name you wish to assign to it.
3. Type the program as shown below:


c programmming online,basic of c language,structure of c programming,c language statements,Compiling a C Program,Pseudo Codes in c,basis data type in c ,variables in C Program,constants in C Program,c operators in C Program,special operators in C ,Decision Making,Branching & Looping in C Program,if statement in C Program,for loop in C Program

No comments:

Post a Comment