|Using Borland C++ Builder 5|
This handout includes details on using Borland C++ Builder 5. Please read through the entire handout before getting started.
Table of Contents
|Part I: Getting Starting|
Your first decision is whether to do your work at the Stern/ITS (formerly ACF) Labs or at Home. If you choose to use the Stern/ITS Labs, goto Option 1. If you choose to work at Home, goto Option 2.
Option 1: Working at the Stern/ITS Labs
If you decide to do your homework at the Stern/ITS labs, consider these tips that I gathered from last semester's instructors:
All kinds of useful info about ITS can be found at http://www.nyu.edu/its
Option 2: Working at Home
If you decide to work at home, you will need to purchase a copy of Borland C++ Builder 5, available from the NYU Computer Book Store. With the academic discount price, Borland costs approximately $50.
Installation from the CD is quite straighforward. One thing to be careful about: at a certain point during installation, you will be asked whether you want to work with files with the .cpp extension, or the .c extension. Be sure to check the button for the .c extension.
|Part II: Compiling and Running a Simple C Program|
Once you have decided on Part I, you are ready to start compiling and running your first simple C program.
There is a (relatively) easy way to do this, and there are slightly more complicated ways. This handout will show you what I think is the easiest way. This way you spend less time getting frustrated with the Borland Builder product, and more time working on your actual C programs (that will be frustrating enough!).
Getting the template.c Program
Starting Borland Builder
You are now ready to start Borland. This differs from lab to home, but somewhere in your Windows Start Menu, you will see "C++ Builder 5." Once you start Builder, your screen should look something like this:
You want to close up all this stuff (but do not exit the Builder application). Choose Close All from the File menu.After choosing File -> Close All, your screen should look something like this:
Close up the Object Inspector (not the Builder application), by clicking the close box (the little x) in the top-right of the Object Inspector.
Now, the trick is, you don't actually create a new file. You open the existing file template.c, which you obtained in a previous step. Follow these steps to open the file template.c
Choose File -> Open (or click the open icon on the toolbar). Your screen should now look something like this:
Be sure to click the Files of type list, and choose C file (as shown in the screen shot). Additionally, of course, you will need to navigate to the drive and folder containing the file template.c.
Open the template file, which you see selected in this snapshot (you will probably not see the .c extension here). You should then see the following on your display:
Builder is asking you if you want to create a project. You do want to, so click Yes. (What is a project? Never mind, at least for now.) Your screen should now resemble the following:
Now immedately rename template.c to some other name (using File -> save as), so that your template.c file remains intact and unchanged for future use. Important: when typing in the new file name in the text box, type out the whole name, including the .c extension. For example, if you want to name your program myprog.c, type myprog.c, not myprog, and certainly not myprog.cpp.
Now, edit the program as desired. To save your editing changes (which you should do often), click the save icon, or hit the Ctrl+s key combination, or choose File -> Save (not Save As, since you are not changing the name or location of the file at this point).
Compiling/Running Your Program
At long last, you are now ready to compile and run your program. Fortuantely, this is actually the easiest step: simply click the right-pointing green arrow on the toolbar, or choose the Run option from the Run menu, or just hit the F9 key.
In this class, we are learning ANSI C (not C++, no Borland-specific goodies, etc). You want to tell the compiler to enforce ANSI C. You don't want to? Yes, I think you do. When you are inside the Builder application, choose Project -> options. Then choose the Advanced Compiler tab. Under Language Compliance, select the ANSI radio button. Then be sure to check Default at the lower-left corner of the Project Options windows, then click OK. Now the compiler will not (should not?) let you get away with nasty non-ANSI C programming.
If you are using the Stern/ITS Labs, note:
Always run your programs from a hard drive, but save them on a floppy (or ZIP, etc.) disk. Let me explain...
When you run a C program file, be sure that the copy of the C program file you're running is not on a floppy disk. Running off a floppy will make compiling and running the program unacceptably slow, and will fill your floppy disk with huge temporary files that you don't want or need, and you will run out of space on your floppy. So, copy the C program file you are working with to your hard disk, or H: partition (in the Stern labs), or the hard disk in the ITS labs (you may be able to use the temp directory for this). But when you end your session, after quitting from Builder, be sure to save your C program file(s) (not the other files with weird extensions, not the .exe files, etc.) to your floppy disk or ZIP disk or whatever. You can copy files with Windows Explorer (best way), or with My Computer.
Do not save your C program file(s) from floppy disk to hard disk, or vice-versa, using File -> Save As. You will often run into messy problems if you do this! Just be sure the Builder application is closed, and use Windows Explorer or My Computer for copying.