ECE-1021

Intro to Borland TurboC/C++ v4.5

(Last Mod: 27 November 2010 21:38:39 )

ECE-1021 Home



Getting Started

Get the C Source Code Template

Start with the C Source Code Template for this course. With most browsers you can retrieve this file by right-clicking on the link and selecting "Save Target As" from the drop down menu. Save this file to a convenient place on your computer. If you are using a network computer at the university do NOT save it to any of the computer's hard drives; instead, save it to your network drive or an external medium such as a USB drive. Do not use a floppy disk as this will result in very slow compile times and possibly even compile failures due to disk size limitations.

Launch the TurboC IDE 

On most computers where the Borland TurboC Integrated Development Environment (IDE) is installed you can launch it by selecting the "Start" taskbar button, then selecting "Programs", then "Turbo C++ 4.5", then finally "Turbo C++".

Open Your Copy of the Template File

From Menu Bar: File - Open (Leftmost button on the standard Toolbar)

On the Dialog Box that is brought up, use the Drives list (lower-right region) to first select the drive that the file is located on and then use the Directories list (upper-right region) to navigate to the correct directory. The template.c should now be in the File list (upper-left region). Open the file by double-clicking the name or single-clicking it and selection the Open button.

Note: You can also create a new file instead of opening an existing one. If you do, be sure to use the correct extension when you save the file as the default will likely be *.cpp and you need *.c.

Make A Copy of this File Under a New Name

From Menu Bar: File - Save As

Select the Appropriate Language Extensions

From the Menu Bar: Options-Project-Compiler-Source

If you do not need the Borland extensions (for functions in <conio.h>):

If you do need the Borland extensions (for functions in <conio.h>):

You may have to perform this step every time you open your file. The reason is that this is a "project" level setting and you have not created a project - so the compiler has no place to store this setting in such a way that it is associated with this particular file. Projects are not required for single-file programs though you may define one if you desire.

Modify the Header

Assuming you are working with a copy of the C Source Code Template, perform any modifications necessary. Guidance is provided in the Style Standards.


Writing/Compiling/Linking/Running

Write Your Program

At this point you would write your program. Since the C Source Code Template is a complete and functional program, we will proceed with the steps necessary to Compile, Link, and Run the program.

Compile Your Program

From the Menu Bar: Project-Compile

Link Your Program

From the Menu Bar: Project-Make All

Run Your Program

From the Menu Bar: Debug-Run

Stopping a Paused Program

Normally, when you run your program, it is expected that it will finish execution and then return you to the IDE. If it doesn't, you have a few options to terminate your program depending on why you need to do so. 

From the Menu Bar: Debug - Terminate Program

If your program is running normally but is waiting for input you can terminate it by selecting this option or by clicking the "x" icon in the upper right corner of the execution window.

Stopping an Unresponsive Program

If your program is not currently waiting for input or gets into an infinite loop, you won't be able to select the Terminate Program option from the Menu in the IDE. 

Clicking the 'x' icon in the upper right corner of the execution window might work as might right-clicking on the execution window's Task Bar icon and selecting "Close". These may or may not be able to stop it. Give it a few seconds to respond, probably with an "Application Not Responding" dialog box from the Task Manager. Select "End Now".

Take note of the section on Unusual Termination below.


Hot Key and Toolbar Short Cuts

Most of these commands also have Hot Key and/or one-click Toolbar shortcuts - to find out what a particular Toolbar button does, position the mouse over a button and read the description in the message line at the bottom of the editor environment window. Learning how to use these shortcuts can be a great time saver.


Using the Debugger

Once you have compiled your code, you can use the integrated debugging capabilities to track down and correct errors. The debugger has a fairly rich set of capabilities - only the most basic of which will be discussed here.

Single Stepping without Pushing Into Functions

From the Menu Bar: Debug - Step Over

    Executes one statement - if any functions are called, it execute that function at full speed.

Single Stepping with Pushing Into Functions

From the Menu Bar: Debug - Trace Into

Executes one statement - if a function is called, it will push into that function. It will not push into standard library functions.

Execute at Full Speed to Present Cursor Location

From the Toolbar: Click on the button to the right of the lightening bolt.

Place the cursor on a line of executable code in the source code file and click on this button. This can also be invoked by pressing F4. There is no menu item available for this action. If you get a message saying that no address is available for the present line, it probably means that the compiler optimized out that line of code. This may or may not provide a clue as to what is going wrong with your program.

Terminating a Program

From the Menu Bar: Debug - Terminate Program

If you are debugging your program and want to stop your program, either because you found an error or just because you want to start over, you use this option to terminate the program. You can also terminate your program by clicking the "x" icon in the upper right corner of the execution window. Another option is to compile and/or rebuild your program. These will generally ask if you want to rebuild the program and, in the process, terminate the version that is presently in a paused mode. You will not be able to tell the IDE to run the program if a version of it is already running - you must terminate the program first.


Unusual Termination

Because the IDE and your program's execution window share the same memory space, your program is capable of corrupting the IDE. Anytime your program throws an error or you have to kill it, be prepared to have to close the IDE and reopen it. You may or may not have to do this - if everything looks like it is working okay, it probably is. If in doubt, exit and restart. It is also possible to corrupt the temporary files that the IDE maintains on your drive to the point that you can't re-launch the IDE. If this is the case, log off the computer and log back on. It should not be necessary to reboot the machine.