How to Write a C Program


How to Write a C++ Program

There are several ways to write a C++ program. You could simply open your favorite text editor, such as notepad, write your program, save it, and then use a command line compiler to compile the program. In fact, this is the method that will be used in this book, until we get to Section IV, the section on Visual C++. If you have a commercial development tool such as Borland C++ Builder™ or Microsoft Visual C++,™then you must follow the instructions for that particular software package. The examples in this book will use the free downloadable version of the Borland C++ compiler. The free Borland C++ compiler does not have the extra development tools and IDE (Integrated Development Environment) that Borland C++ Builder has. The Web address to go to and download this free C++ compiler is listed in Appendix A. However, the free download is simply a command line compiler. A command line compiler is one that is executed from the command line. This, of course, begs the question of what is a command line. When you enter commands at a DOS prompt (Microsoft Windows™98), Command Prompt (Microsoft Windows 2000/XP), or Shell (Linux/Unix™) you are typing commands on a line, thus the term “command line.” You literally type in commands one line at a time. Figure 1.1 shows the basic DOS prompt for Windows 95/98™.

click to expand
Figure 1.1: DOS Prompt.

To use a command line compiler, like the free C++ compiler from Borland, you simply type the code into a document in any text editor, then save it with a .cpp extension (e.g., myprogram.cpp). That .cpp extension stands for C Plus Plus. C files that are done in a text editor are saved with the extension .c, as you might expect. Complete instructions for how to download, install, configure, and use this compiler can be found in Appendix D. You should use the instructions in Appendix D to make sure you have the compiler properly installed on your PC before continuing with this book.




C++ Programming Fundamentals
C++ Programming Fundamentals (Cyberrookies)
ISBN: 1584502371
EAN: 2147483647
Year: 2005
Pages: 197
Authors: Chuck Easttom

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net