Sams Teach Yourself C in 21 Days

(singke) #1
Getting Started with Dev-C++ 891

G


Running a Program Created with Dev-C++

From the dialog presented in Figure G.10, you can also run the program. You do this by
selecting the Execute button. If the program is a DOS program—as the one in Listing
G.1 is—a DOS windows will be opened and the program will be ran. When the program
ends, the DOS window will automatically be closed. Figure G.11 presents the Sample.c
program being executed by pressing the Execute button. If the dialog presented in chap-
ter Figure G.10 is already closed, you can run the program by either pressing the F9 key
or by selecting Run from the Execute menu option.

FIGUREG.11
Executing your pro-
gram from the Dev-
C++ IDE.

Thesystem(“PAUSE”)command in line 8 prompts you to press a key before the program
will end. In most of the programs you create in this book, there will not be a pause com-
mand. This means that you may not notice the program run. This is because the DOS
window will open, the program will run, and then the DOS window will immediately
close. To get around this, you can open a DOS window yourself. A DOS window can be
opened by selecting Command Prompt from the Accessories menu option on the
Program Options menu from the Start menu of Windows. Once you have opened a
Command Prompt window, you can change to the directory you saved your program.
Once there, type the name of the program with no extension to run it. Figure G.12 pre-
sents the Sample program running in a Command Prompt window.

50 448201x-APP G 8/13/02 11:22 AM Page 891

Free download pdf