Exercise: Download
Borland C++ 5.5 compiler from Borland
website, install it, and use a small program for testing it and practicing
debugging.
Step 1: Download files:
- Go to the Borland download web site
at: http://www.borland.com/bcppbuilder/freecompiler/
- Download the appropriate files for your
home system to a temp or download directory:
Borland C++ 5.5 Compiler (8.7 MB)
- You will be asked to register and
complete a survey before downloading these files.
- Note: The
download file is 8.7 MB. If you use a modem at home and your computer has
a zip drive, you may want to download the files onto a zip disk in the labs at
school, and install it on your computer at home from the zip disk. This
approach might be easier than downloading over a modem connection.
Step 2: Unzip and Install files:
- Unzip the file you downloaded to an
install directory.
- In the subdirectory created by
unzipping, run the "intall.exe" file to install the
software, the documentation, and the sample files.
- Read the README.TXT file in the
Borland\BCC55 directory to find out what you need to do to create the
necessary configuration files (bcc32.cfg and ilink32.cfg) to specify the
appropriate paths for include files and library files. You can create
these configuration files using Notepad and save them in the BCC55\BIN
directory.
- If you know how to set the DOS path for
your computer, modify it to include the Borland\BCC55\BIN directory. If
you do not know how to modify/set your DOS path, you can use Notepad to make a
small batch file that you can use to run the Borland C++ compiler from your
programs directory. The contents of this batch file would be:
c:\borland\bcc55\bin\bcc32 -I -L %1
if you have installed Borland BCC 5.5 to the C: drive. Save the file as
"bcc.bat" in the directory where you will be writing programs.
To use the batch file to compile a C program, you would enter:
bcc filename.c
where the filename is the name of your file and .c is the file extension for a
C program.
Step 3: Using Borland C++
- Borland C++ is a command-line (DOS)
application, so you will need to use a DOS window for compiling
programs. If you have set the DOS path, or created a batch file in your
programs directory (i.e., whatever directory you want to use for writing
programs), you will use a command line instruction to run the compiler.
The command line to run the Borland C++ compiler would be either:
bcc32 -I -L filename.c
if you have configured the DOS path, or
bcc filename.c
if you are using a batch file the same directory as your program.
- To edit programs, you can use either
Notepad or the DOS Edit utility in a DOS window. The DOS Edit utility
may be easier to use than Notepad since it provides line numbers and position
numbers within a line. You can open separate DOS windows for editing a
file and for compiling a file --- that allows you to shift back and forth
between your editing window and your compiling window.
Step 4: Type in a small C program
to practice using the command line compiler:
-
Use DOS Edit to type in the "Hello, World" program, and save it in your programs directory as "hello.c".
/* Hello, World Program */
#include <stdio.h>
int main ()
{
printf ( "Hello, World!\n" );
return 0;
}
- Use a separate DOS window to compile and
run the program.
To compile using the batch file, type in
bcc
hello.c
or, if you have set the DOS path, type in
bcc32 -I -L hello.c
Note that the switches for Borland C++ are case sensitive.
- Use the DIR instruction to examine the
file directory. If everything compiled and linked correctly, you should
see your original "hello.c" file, plus additional files named
"hello.obj" and "hello.exe" The "hello.exe"
file is the executable file.
- To run the program, type in the name of
the executable file. It is not necessary to include the .EXE extension.
hello
You should see the "Hello, World" message on the screen.