Start Dev
Start Dev
Jacqueline A. Jones
Introduction
Dev-C++ provides an integrated environment for writing programs. "Integrated
environment" means Dev-C++ is a combination program, consisting of a text editor and a C++
compiler. A text editor is a limited word processing program that allows you to type in your
program, make corrections and changes, and save and retrieve your program from disk storage.
The editor is integrated with the Dev-C++ compiler so that you can easily switch between editing
your program and compiling and running it. Note that the Dev-C++ compiler allows you to
write, compile and run programs in either C++ or C.
In order to use Dev C++, you must know how to use the computer, how to get around in
the integrated environment, and how to use the editor. We've divided this material up into four
sections. Everyone should read Sections 1, 2 and 4. The instructions assume you are working in
the lab at Brooklyn College; if you are planning to work at home, you should read Section 3 on
Downloading and Installing Dev-C++.
Section 1: The Basics. This is a quick overview of the basics you will need to run your first
few programs. This section is a quick summary of what to do.
Section 2: The Details. This is a more detailed overview of the basics covered in Section 1.
Section 3: Downloading and Installing Dev C++. This is for those of you who want to work on
your computer at home.
Section 4: Editing, Saving, and Retrieving Files. This discusses editing files and using the File
menu.
For example, you might name your first assignment (saved on a flash drive) as follows:
d:prog1.cpp
4. Compile your program by selecting Execute | Compile or by clicking on this icon
above the edit window. If your compilation is successful, a Done message will appear;
click OK to return to the editor. If your compilation is unsuccessful, an error message will
appear; click OK to view a list of errors that you must correct. Use the editor to correct the
errors, and repeat step 4 until you are successful.
5. Execute your program by selecting Execute | Run or by clicking on this icon:
6. Print your program by selecting File | Print or by clicking this icon.
In the window that pops up, remove any check mark in the box that says Line numbers.
(With line numbers, your printed lines may run off the page.) Click OK.
7. To print your output, place the cursor in the bar at the top of the output window and rightclick. From the menu that pops up, place the cursor over Edit, and another menu will appear to
the right. Move the cursor to the new menu, and click on Select All. The window contents will
change color. Again place the cursor in the bar at the top of the output window and right-click.
From the menu that pops up, select Edit and then Copy. Then go back to the Dev-C++
environment. Open a new editor window by selecting File | New | Source file. Place the cursor
in the new window that opens, select Edit | Paste, and the output will be copied into the new
window. Save it, if you wish, using a name like prog1.out. Then print it as you printed the
program file in step 6.
8. Exit from Dev-C++ by selecting File | Exit, or by clicking on the Close icon at the
top right corner of the Dev-C++ window.
Figure 3
As you type in your program, you will notice that Dev-C++ uses different colors for
different elements of your program; this is called syntax highlighting. The colors can be
changed, or you can choose to have everything displayed in one color. Syntax highlighting can
help you in debugging your program; for example, if you have typed in a keyword and it doesn't
appear in boldface, the word is probably misspelled. If you have forgotten to terminate a
comment, all the text following it will be in the same color as the comment.
To leave the "Save File" window and save your file, press <Enter> or click Save with
the mouse. You can leave the window without performing any action by selecting Cancel.
Once you have named a file, subsequent Save operations will not bring up the File Save
window. Changes will be noted only by two small changes in the appearance of the Dev-C++
window. The Save icon will become gray to indicate that the save action can not be performed at
this time. In addition, the word "Modified" will disappear from the status line at the bottom of
the window.
WE RECOMMEND THAT YOU SAVE YOUR FILE EVERY FIVE OR TEN
MINUTES.
If you do not save your file, and the computer crashes or someone kicks out the plug, you
will lose all your unsaved work. It is better to lose less work by saving every few minutes.
Dev-C++ automatically saves your file before compiling it. This can cause two surprises:
1) the Save File window may appear asking you to name the file, and 2) if you are making some
"what if I do this" kinds of changes, you may lose the original version of your program. If you
want to keep more than one version of a program, use the File | Save as feature to save the file
with a different name.
However, if the compiler finds any errors during the compilation of your program, it will
not display this box, but will instead provide a list of error messages and highlight the first line
with an error, as shown in Figure 6.
From this menu, move the cursor to Edit, which will bring up the sub-menu shown in Figure 8.
Sample Program
Here is a complete sample C++ program. You should enter, compile and run it. This
program sends one line of output to the screen.
/* sample C++ program */
#include <iostream>
using namespace std;
int main()
{
cout << "my first C++ program" << endl;
system("pause");
return 0;
}
Click on the word "Download" in the green box. A new page will appear with these words:
"Your download should begin shortly." Typically, your download will begin automatically.
Downloading Using Firefox
In Firefox, this window will appear:
When the download has finished, the name of the setup file will appear in place of the
progress bar.
You can choose Save or Run. Choosing Save stores the downloaded file, while choosing Run
does not. We've chosen Save. If you choose Save, you will have to run the setup separately after
the download.
When the download starts, you can watch progress by percentage at the bottom of the
window:
It saves the file in your chosen download folder (usually Downloads) When done, you will see
this window.
tests some changes that you aren't quite sure of). To do this, use the Save as selection from the
File menu. Save as allows you to save a file under a name other than its original name. The
dialog box that appears will be identical to the one shown in Figure 4, and the actions you take
will be similar. Later, you can retrieve either file.