Thursday 11 February 2016

C++:2.Using Turbo C++

SETTING UP TURBO C++

Turbo C++ provides a highly automated installation procedure. In general, you need only follow the prompts and answer the questions. However, you can help optimize your system by answering a few of the questions in specific ways.



MEMORY MODELS: The installation program will ask you what memory models you want touse. It you don't know about memory models, this question may seem obscure.
The segmented architecture of the 80x86 microprocessor is the culprit. A program consists of code and data. Code or data that fits within a segment, which can be up to 64kb long, executes quickly. When code or data exceeds the 64k limit, it must be accessed in a less efficient way, and the program executes more slow. Depending on the size of the code and data in the program, the developer must select a memory model large enough to accommodate the program, but not unnecessarily large, lest execution speed be reduced.
Table summarizes the memory models and the number of 64k segments available with each one.



THE DEMONSTRATION TOUR

During the installation in Turbo C++ you are also asked to choose whether you want to install the demonstration tour. This tour, which shows how to use the IDE, is important if this environment is new to you. If you've had experience with Turbo Pascal, you may no need the tour.

YOUR FIRST PROGRAM

In this section we'll show how to develop a C++ program, using the Turbo C++ Integrated Development Environment.

INVOKING TURBO C++

To start Turbo C++ move to the directory in which you plan to do your C++ program development.

USING THE EDITOR

The cursor should now be positioned in the upper-left corner of the Edit window. You can start typing your program. Here is it:



You will find that operating the editor built into the IDE is quite intuitive. What you type will appear on the screen, and you can see the arrow keys to move the cursor. Pressing the ENTER key inserts a new line and drops the cursor to the start of the line. The BACKSPACE key deletes the character to the left of the cursor.



SAVING YOUR PROGRAM 

Once you've typed in your program, you should save it to the disk be selecting Save form the File menu, or by pressing F2. It's good to do this before compiling and running your program, so that if a bug crashes the system you won't lose the changes to your source file.

COMPILING AND LINKING

The program that you type into the Edit window constitutes the source file. When it is saved to disk, it is an ASCII file similar to that generated by a word processor. It  has the .CPP file extension.
Remember that a source file is not an executable program; it is only the instructions on how to create a program. Transforming your source file into an executable program requires two steps.
First, you must compile the source file into an object file. The object file which has an .OBJ extension, contains machine-language instructions that can be executed by the computer. However, these instructions are not complete. A second step, called linking is required.
The linking step is necessary because an executable program almost always consists of more than one object file. Linking combines the object files into a single executable program.



RUNNING THE PROGRAM

To run the ,EXE file, select Run from the Run menu. You'll see the screen flicker briefly. Where is the output of the program? To see it, select User screen from the window menu, or type  ALT-F5. The IDE will vanish, and you'll see the normal DOS screen, with the following display:



ERRORS

It may be that you were unclear on the syntax of a particular statement, or that you made a typing error. Such errors can be discovered by the computer or by the linker, or they can appear at run-time.

COMPILER ERRORS

LINKER ERRORS

RUN-TIME ERRORS

No comments:

Post a Comment