Sams Teach Yourself C in 21 Days

(singke) #1
Getting Started with C 11

1


This statement instructs the computer to display the message Hello, Mom!on-screen.
(For now, don’t worry about how this statement works.)

Using an Editor
Most compilers come with a built-in editor that can be used to enter source code; how-
ever, some don’t. Consult your compiler manuals to see whether your compiler came
with an editor. If it didn’t, many alternative editors are available.
Most computer systems include a program that can be used as an editor. If you’re using a
Linux or UNIX system, you can use such editors as ed, ex, edit, emacs, or vi. If you’re
using Microsoft Windows, Notepad or WordPad is available. If you’re using MS/DOS
5.0 or later, you can use Edit. If you’re using a version of DOS before 5.0, you can use
Edlin. If you’re using PC/DOS 6.0 or later, you can use E. If you’re using OS/2, you can
use the E and EPM editors.
Most word processors use special codes to format their documents. These codes can’t be
read correctly by other programs. The American Standard Code for Information
Interchange (ASCII) has specified a standard text format that nearly any program, includ-
ing C, can use. Many word processors, such as WordPerfect, Microsoft Word, WordPad,
and WordStar, are capable of saving source files in ASCII form (as a text file rather than
a document file). When you want to save a word processor’s file as an ASCII file, select
the ASCII or text option when saving.
If none of these editors is what you want to use, you can always buy a different editor.
There are packages, both commercial and shareware, that have been designed specifically
for entering source code.

To find alternative editors, you can check your local computer store or com-
puter mail-order catalogs. Another place to look is in the ads in computer
programming magazines. This book includes on its CD two compilers that
also include editors. These are the Bloodshed Dev-C++ and DJGPP. Check the
files on the CD and Appendix G, “Bloodshed Dev-C++,” for more informa-
tion on these programs.

Note


When you save a source file, you must give it a name. The name should describe what
the program does. In addition, when you save C program source files, give the file a .c
extension. Although you could give your source file any name and extension, .c is recog-
nized as the appropriate extension to use.

03 448201x-CH01 8/13/02 11:14 AM Page 11

Free download pdf