|
|
|
|
|
|
|
To make this work, you'll need to tell your compiler to create a console application. Some compilers, written to be used with Windows or the Mac or another windowing environment, call this a quick window, or a simple window, or perhaps a console window. |
|
|
|
|
|
|
|
|
Your compiler can have its own built-in text editor, or you can use a commercial text editor or word processor that can produce text files. The important thing is that whatever you write your program in, it must save simple, plain-text files with no word processing commands embedded in the text. Examples of safe editors include the Windows Notepad, the DOS Edit command, Brief, Epsilon, EMACS, and vi. Many commercial word processors, such as WordPerfect, Word, and dozens of others, also offer a method for saving simple text files. |
|
|
|
|
|
|
|
|
The files you create with your editor are called source files, and for C++ they typically are named with the extension .cpp, .cp, or .c. In this book, all the source code files are named with the .cpp extension, but check your compiler for what it needs. |
|
|
|
|
|
|
|
|
Most C++ compilers don't care what extension you give your source code, but if you don't specify otherwise many will use .cpp by default. |
|
|
|
|
|
| DO | DON'T | | DO use a simple text editor to create your source code, or use the built-in editor that comes with your compiler. | DON'T use a word processor that saves special formatting characters. If you do use a word processor, save the file as ASCII Text. | | DO save your files with the .c, .cp, or .cpp extension. | | | DO check your documentation for specifics about your compiler and linker to ensure that you know how to compile and link your programs. | |
|
|
|
|
|
|
Compiling and Linking the Source Code |
|
|
|
|
|
|
|
|
Although the source code in your file is somewhat cryptic, and anyone who doesn't know C++ will struggle to understand what it is for, it is still in what we call human-readable form. Your source code file is not a program, and it can't be executed, or run, as a program can. |
|
|
|
|
|