Creating Simple Single-File Programs
(Last Mod: 04 November 2010 18:09:28 )
Borland Turbo C/C++ v4.5 For Windows
Launch the Editor
From Menu Bar: File - New
From Menu Bar: File - Save As
Save this file with an appropriate name and in an appropriate place. Do not work off of a floppy when at all avoidable. Turbo C creates some rather large files and you may run out of disk space. At the least, your compile and link times will be much longer than necessary.
Use a ".c" extension and not the ".cpp" extension that will likely be offered as the default. A *.cpp extension will invoke the C++ compiler which imposes some slightly different rules for C++ code than for C code.
Do NOT blindly save the file in the directory that Borland offers as the default. This is very possibly a directory within the Borland file structure and user files do not belong there.
From the Menu Bar: Options-Project-Compiler-Source
Set for ANSI C by choosing "ANSI"
You will have to perform this step every time you open this 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.
Write your program.
From the Menu Bar: Project-Compile
This will compile the code. Errors and warnings will be reported in a separate window.
Remember that compiling is not enough to get your executable file. You must still Link the code.
From the Menu Bar: Project-Make All
This will Link the code. Again, errors and warnings will be reported in a separate window. If you receive a warning about there not being a module definition file specified, ignore it. The defaults are what you want.
From the Menu Bar: Debug-Run
This will launch a window and run your program in it. After it finishes the window will go inactive and you will probably have to close it manually by clicking the 'x' icon in the upper right corner.
Most of the above actions can be accomplished with Control Keys and/or clicking buttons on the Tool Bar. Learning how to use these shortcuts can be a great time saver. You also want to explore the debugging capabilities. In particular, how to step through the code and how to set up watch windows.