1.1. Turbo C++ IDE.
The compiler used for C language is
called turbo C++. It is the implementation of Borland International for C
language. Turbo C++ also provides a complete Integrated Development
Environment (IDE) known as TC Editor. It is used to create, edit and
save programs. It also provides a powerful debugger. The debugger helps users
in detecting and removing errors in programs. The process of writing programs
in Turbo C editor is very easy. The user can type “TC” on DOS prompt or double
click TC shortcut to start IDE. The menu bar of IDE contains menus to create,
edit, compile, execute, and debug a C program. The user can open a menu by
clicking on it by mouse. The user can also press a combination of ALT key and
the first highlighted character of the name menu. For example, ALT+F is used to
open file menu.
1.2 Creating and Editing a C Program
Figure 2.2: Create a new file in a new edit widow
|
This edit window has a double-lined
border. The cursor blinks in the window. The position of the cursor indicates
the starting point to write a program. The user can expand the window by
clicking the arrow in the arrow in the upper right corner. The user can also select
Window > Zoom to expand the window. The vertical and horizontal
scrollbars are used to navigate through the program.
1.3 Saving a C program
The process of storing the program on
disk is known as saving. A program should be saved on disk to be used
repeatedly. C programs are saved with .c extension. For example, a
program can be saved like program.c. The following procedure is used to
save a C program:
1. Select File > Save OR press
F2 key. The Save File As dialog box will appear. The default name
NONAME00.CPP appears in the dialog box.
2. Enter the file name.
3. Enter the path to save file. The
default location to save programs is BIN directory.
4. Click OK. The program will be
saved at specified location with specified name.
1.4 Compiling a C program
The process of converting source
program into object program is known as Compiling. The program saved
with .c extension contains the statement of C language. It is known as source
program. The source program cannot be executed by computer directly. A compiler
converts the source program into object program and saves it in a separate
file. The object program is saved with .obj extension.
The source program cannot be compiled
if it contains any syntax error. The compiler generates error message to
describe the cause of error. All errors must be removed to successfully compile
a source program.
The following procedure is used to
compile a C program:
Select Compile > Compile OR
press ALT+F9 key. The program will be translated into object program if
it contains no error. The compiler will generate error message if the program
contains any error.
Figure 3.4: Compile
C program
|
1.5 Linking a C Program
The process of linking library files
with object program is known as linking. These files are used to accomplish
different tasks such as input/output. A library file must be linked with
the object file before execution of program. A program that combines the object
program with additional library files is known as linker. It is part of
C++ compiler.
The linker generates error message if
the library file does not exist. A new file is created with .exe extension
if the process of linking is successful. The file is known as executable
file and can be executed by the compiler directly. The linker can be
invoked in Turbo C++ by selecting compiling > Link form the menu bar.
1.6 Executing a C Program
The process of running an executable
file is known as executing. The C++ program can executed after compiled and
linking. The program must be loaded into the memory to execute. A program that
places an executable file in the memory is known as loader. The program can be
loaded in the memory by selecting Run > Run from menu bar or passing CTRL
+ F9.