GETTING
STARTED
If Dev-C++ is not running then click on the windows Start button and put the cursor on Programs. This will display the names of application programs. Next put the cursor on Bloodshed Dev-C++ and click on Dev-C++. This will start the Dev-C++ application. A Dev-C++ window will appear. At the top of the Dev-C++ window is the menu bar with menu items File, Edit, … , Execute, Debug, …. To select a Dev-C++ command, put the cursor on the desired menu item in the menu bar and click on it. This will display a detailed menu of related commands. Click on the desired command.
1.Click
on the File menu item. Then position the cursor on the New command.
Then click on Source File.
2.Now
type the C program in the file window.
3.When
finished, click on the File menu item again. Then click on the command Save.
A Save File window will
appear. If you are working in the lab you want to save all your files on
your floppy disk so insert a floppy disk into the floppy disk drive. At
the top of the Save File window there is a Save in: slot.
This slot shows the folder or disk drive where the file will be saved. If this
slot does not already show 3½ Floppy (A:) then click the down arrow at
the right hand side of the slot. This will display the other folders and disk
drives. Click on 3½ Floppy (A:). At the bottom of the Save File window there is a File
name: slot. If this is a new file
you will see the name Untitled in this slot. Position the cursor at the end
of this name and click. Then back space to erase this name. Type the name you
have chosen for your file ending in .c
to indicate that this is a C source
file. If it were a C++ source file you would end the file name with .cpp. For example you might chose prog1.c as the file name. You can see all the possible types of files by clicking
the arrow at the right hand side of the Save as type: slot.
4.Now click the Save
button. You can now click the File menu item again and click on the Close
command. You could also have started this whole process of saving the file by
clicking on the Close command.
5.On
your home computer you can save your file in a folder if you want to. On the
computers in the lab you must save all your files on your own floppy disk as
explained above.
1.Insert the floppy disk containing the program source file into the floppy disk drive.
2.Click
on the File menu item. Then click on the Open Project or File command.
An Open File window will appear.
The Look in: slot will show the folder or disk drive you
can open a file from. If this does not show 3½ Floppy (A:) then
click on the arrow at the right hand side of the slot and click on 3½ Floppy
(A:). You will now see a listing of the files on you floppy. Double click
on the file you want to open. Or you can single click it and then click Open.
Now your file will be displayed in the Dev-C++ file window and you can edit it.
3.To
edit the file you can move the file cursor indicating the position in the file
by the arrow keys or by using the mouse to position the mouse cursor and
clicking. You can delete characters by pressing the backspace key. You can
insert characters by typing them. You can also cut/copy a block of text and
paste a block of text. To do so use the mouse to drag the mouse cursor over the
text you want to cut/copy so that it is highlighted. Now click on the Edit menu
item and click on the Cut or Copy command. To paste a
block of text position the file cursor where you want the block of text
inserted. Then click on the Edit menu item and click on the Paste command.
4.To save the edited program click on the File menu item and then click on the Save or Close command.
5.On your home
computer the file you want to edit may be in a folder. In that case open it
from the folder.
1.Open the program file. Then click on the Execute
menu item
and click on the Compile & Run command. If the program compiles correctly
then a console input/output window will appear where input/output for the
program takes place.
2.If the program does not compile correctly then a
list of compiler errors will appear at the bottom of the Dev-C++ window. You
must then edit the program to correct these errors.
2.It
is harder to print the information in the console input/output window. To do so
put the cursor at the top margin of the input/output window and right click, i.e.
press the right button on the mouse. A menu will pop up. Click on Edit
in this menu. Another menu will pop up. In this menu, click on Mark. Now
drag the cursor over the text so that it is all highlighted. Right click at the
top again and click on Edit again. In the menu that pops, click on Copy.
This will copy the highlighted text into the editor buffer. Now you must paste
it into some text editor window. For example, start the Microsoft Word application.
A blank Microsoft Word Document window will appear. In this window click on Edit and then click on the Paste
command. The text that was copied
from input/output window should now appear in the document window. You can now
print this document or save it.
You
cannot delete a file from your floppy disk from inside Dev-C++. One way to
delete a file is to double click on the My Computer icon and then
double click on 3½ Floppy (A:). This will display the files on your
floppy disk. Now single click on the file name you want to delete. This will
highlight the file name. Click on the File menu item and then click on
the Delete command.
As soon as program
execution terminates the console input/output window closes. This occurs too
fast to even see the results. To prevent this you must insert at the end of the
program some instructions that prevent the program from terminating until you
type something. There are 2 methods to do this.
#include <stdio.h>
int main()
{
. . .
getchar(); <<<
getchar(); <<<this
prevents the input/output window from closing until the user presses the return
key 1 or 2 times.
return 0;
}
or
#include <stdio.h>
#include <stdlib.h> <<<this is needed
because stdlib contains the system function
int main()
{
. . .
system(“PAUSE”); <<<this
prevents the input/output window from closing until the user presses any key 1
time.
return 0;
}
Dev-C++ has an interactive debugger that can help
you debug programs that compile, but give the wrong results. Before the
debugger can be used you must have the compiler/linker option set to generate
debugging code. Ask the TA about this when you first use the debugger.
Typically to use the debugger you place a stop somewhere in the program where
you would like for execution to stop. You do this by clicking in the left
margin next to the instruction. This should highlight the instruction and place
a check mark in the margin. Then click on the menu item Debug and click on the command Debug.
This starts program execution that will be stopped at the highlighted
instruction. You can then step through the following instructions one at a time
by clicking Next Step. When you have stepped through as many
instructions as you want to, click on Step Over. You can also watch the
value of any variable by clicking the Add Watch command and then typing
the variable name you want to watch. The debugger will then show the value of
the variable after each step.
If
a program consists of several source files and your own header files then you
must make these into a project. You do this by clicking on the File menu item and then putting the cursor on New. In the menu that pops
up, click on Project. In the window that appears double click on Empty Project. Give the project a name and save it. You add files to the project by
clicking on the Project menu item and clicking on the Add to
Project command. You should have all your source files and all you
own header files, if any, in the project. To compile and run the project just
click on the Execute menu item and the Compile & Run command
as usual.