Installing Turbo C++Turbo C++ compiler is commonly available on CDs and on web resources. This installation process of turbo C++ is very simple and easy. It provides "install" program used to install the Turbo C++ compiler. Simply, run the "install" program and follow the instructions such as;
|Step 1: Click to "Next" button to continue Turbo C++ installing.|
|Step 2: Check lisnece agreement box and click "Next" button.|
Select the drive and directory name where Turbo C++ is to be installed. By default, directory name is TC on the root of drive C.
When Turbo C++ is installed, the TC directory is created on the hard disk.
This directory / folder contains different subdirectories such as:
INCLUDEIt contains the header files.
LIBIt contains the library files.
BINIt contains the main executable file "TC.EXE" of Turbo C++ editor and Linker etc.
Loading Turbo C++ EditorWe can create a shortcut of "tc.exe" on the desktop to load the TC editor by simply clicking the shortcut. Similarly, We can also load TC editor through Run option of Start menu.
How to load TC editor through Command prompt?Turbo C++ editor has an executable file "TC.EXE". By default, it is in the directory path "c:\tc\bin". When this file executed, the IDE of Turbo C++ editor appears on the screen along with its development tools.
Following procedure is used to load Turbo C++ editor:
Go to DOS prompt. By default, it will appears as:C:\WINDOWS>
Change the directory to TC\BIN by applying command:
C:\WINDOWS> CD\TC\BIN (press Enter key)
The prompt will appear as:
Type TC and press Enter key. The Turbo C++ editor is loaded and IDE window will appear on the screen as shown in the following image.
How to set up directories of Turbo C++?By default, the source file, object files and executable files are stored in the current directory (or BIN directory). It is not the right place for storing these files. These files should be stored in separate relevant folders. A user can set specific directory path to store source files and output files (such as object files and executable files).
Following is the procedure to set the different directories path:
Select Directories from Option menu of Turbo C++ IDE window. A window will appear with four fields / text boxes as shown in the image.
Set the path for header files in the Include Directories filed such as "C\TC\INCLUDE".
Set the path for library files in the Library Directories filed such as "C:\TC\LIB".
In Output Directory the compiler stores the object files and Linker stores the "exe" files. Set the path for output files.
In Source Directories the Turbo C++ editor stores the source files. Set the path for source files I.e "d:\MyCppPrograms".
Click on the OK. The new setting will be applied.
Introduction to Interface of Turbo C++ IDEThe interface of Turbo C++ editor is very simple. When IDE screen appears, the menu bar is activated. It contains various menus such as:
FileThis menu contains group of commands used for saving source program, opening existing source program, printing source code of program and exiting from Turbo C++ IDE etc.
|Turbo C++ File Menu|
EditThis menu contains group of commands used for editing C++ source program. These commands include Copy, Cut, Paste and Undo etc.
SearchThis menu contains group of commands used for searching specific word as well as replacing with another one.
|Turbo C++ Search Menu|
RunThis menu contains group of commands used for running C++ program.
|Run Menu of Turbo C++|
CompileThis menu contains group of commands used for compiling C++ program.
|Compile Menu of Turbo C++|
DebugThis menu contains group of commands used for debugging C++ program.
|Debug Menu of Turbo C++|
ProjectThis menu contains group of commands used for opening, closing and creating projects.
|Project Menu of Turbo C++|
OptionsThis menu contains group of commands used for configuring IDE of Turbo C++ and setting up directories etc.
|Options Menu of Turbo C++|
WindowsThis menu contains group of commands used for opening and closing various windows of IDE.
|Windows Menu of Turbo C++|
HelpThis menu contains command for getting help about specific topic of C++ language. We can also get help by pressing F1 key. Similarly to get help about a specific keyword or identifier of C++, type a word, keep cursor on the word and press keyboard shortcut Ctrl+F1.
|Help Menu of Turbo C++|
How to create and edit C++ Program in Turbo C++ editor?The process of writing a new C++ program by following the rules of C++ language is called creating a C++ program. Usually new C++ program is written in Turbo C++ editor. However, the source code of C++ program can be created in any text editor (i.e notepad) but the extension of the source program file must be CPP.
The process of writing, modifying and deleting C++ program statements is called editing C++ program.
How to Save C++ Program in Turbo C++ editor?The process of storing the same program on the disk is called saving the program. The file extension of the C++ program is ".cpp". After writing or editing the source program, it should be saved on the disk.
Following is the procedure to save source code in Turbo C++ IDE:
Select Save command from the File menu or press F2 key. A dialog box will appear. The default file name for source code is "NONAME00.CPP".
- Select the location (drive and specific folder), where program source code is to be saved.
- Type the name of file such as "first" and press Enter key. Turbo C++ editor automatically assigns the program file extension as ".cpp".
Note: we can compile and run the C++ program in Turbo C++ IDE without saving it first but it is not a good practice. We should save the program before compiling and executing it, because sometimes our program may be hanged during execution and the source program code may be erased (lost) from the main memory.
How to Compile C++ Program in Turbo C++ editor?The source code of the program is written by following the rules of the programming language. The source code is not understandable by the computer. The source code must be translated into machine code before running on the computer. The process of translating source code into machine code is called compiling the program.
The C++ compiler is used to translate the C++ program source code into the machine code. The translated code is called object code. When C++ compiler translates the source code, a new file is created for object code with extension ".obj". The first part of the name of object file is same as that of source file. For example, if source file name is "test.cpp", then object file name will be "test.obj".
Following is the procedure to compile the C++ program in Turbo C++ IDE:
- Press keyboard shortcut Alt+F9. (OR Select Compile command from Compile menu.)
- If there is no error in the source code, it will be translated to object code successfully. If there are errors in the source code, compiler will not compile (translate) the source code. It will report the errors in the source code. All the errors must be removed from the source code for its successful compilation.
How to Linking C++ Program in Turbo C++ editor?Linking is the process in which the object file produced by the compiler is linked to many other library files. This work is done by the Linker. Linker is a program and is a part of compiler.
After linking the object code to the libraries, an executable file with extension ".exe" is created. For example, if object file name is "test.obj", then executable file name will be "test.exe".
In Turbo C++ environment, program is linked as:
- Select Link command from Compile menu of the Menu bar.
- In Turbo C++ IDE, compiling and linking can be performed together in one step. To do this, select Make command from Compile menu or press F9 key.
Linker can also detect errors. For example, if the source code uses a library function that doesn't exist, the linker generates an error. If there is any error in the source code, the Linker does not create the executable file (.exe). In this case, the errors are removed from the source code and source code is compiled again. The new object file is then linked to the libraries to create the executable file.
After successfully compiling and linking the C++ program, it can be executed on computer. The process of running the program on computer is called executing program.
How to Execute Program in Turbo C++ ?
The program must be loaded into memory for execution. This work is done by the Loader. Loader is a program that loads the executable file from disk into memory. For example, in Windows environment, when the name of an executable file is double clicked, the Loader loads the file into the computer memory (ram) for execution on the CPU.
In Turbo C++ editor, the program can be compiled and run by pressing the shortcut key Ctrl + F9 or by selecting Run command from Run menu of Turbo C++ IDE. The program is first compiled and then run on the computer.
When the program is run, it's output is displayed on the screen but not to the IDE window. To see the program's output, select User screen from the Window menu (or press keyboard shortcut Alt + F5). You will see the normal DOS screen with program output.
I hope this article helped you. Being a good Programmer, subscribe our blog "Programming Explain" to get latest updates about programming. Don't forget to share and comments. Thanks !