# Notes for Using Dev-C++

## What is a Development Platform

Homework assignments in CSCI 2610 and CSCI 2611 require you to use the more elaborate Dev-C++ system instead of the Cute C system.

Like the Cute C system, the Dev-C++ Development Platform (DP)includes both a source file editor and a compiler.

### Concepts

Make sure you understand the following concepts:

Source File
  A document file written in a high level language such as C++. It is represented in the computer by ASCII codes.
Project File
  The Project File contains organizational details about a program you are working on.
Code File
  The translation of your source file into machine language which is ready to run on the computer. It is represented in the computer by binary numerical codes. Dev-C++ usually places this in the same directory as the project file.
Editor
  The part of the DP which allows you to create and alter your source file and your project file.
Compiler
  The part of the DP which translates your source file into your code file. It must be used every time you make ANY changes to your source file. Usually, the DP keeps track of this for you and will automatically RE-compile your source file after you change it and before you try to run the code file. HOWEVER, sometimes this mechanism fails and you must force the DP to compile your source file.

## Creating a new Program

Use these steps when creating a new program.

They assume you will keep your work on your own diskette - which you must have with you.

1. Start logging onto the NT system (read the directions on the east wall of Austin 320).
2. Your instructor should have given you the user code and password.
3. Double click the desk top icon labeled Dev-C++, and wait for the application to start.
4. Select menu items: File then New Project.
5. In the resulting New Project dialog box select the icon Empty Project on the right.
6. Click the OK button.
7. In the smaller New Project dialog that now pops up, fill in the edit box labeled Project name with the name of your program (without path or extension).
   - This tutorial will use the name myprog as an example.
   - You may substitute your own choice of name wherever you see myprog below.
   - It is best to use letters and digits only.
   - DO NOT include a blank.
   - For example enter:

         			myprog

8. Click the OK button.
9. A file selection dialog Create New Project will now appear.
10. In the Save in drop down list at the very top of the dialog, select the drive and directory you wish to work in. Usually this will be:

        		3 1/2 Floppy (A:)

11. The entry box at the bottom labeled File Name will probably already have the following in it:

        		myprog.dev

    This is the name of your Project File.
12. Click the Save button and wait a little.
13. In the left side panel you will now see a "Project Tree" - this is like the directory tree produced by using the Windows Explorer application. In this tree will be a source file named Untitled.
14. You will change this source file's name to something more appropriate. Thus click it with the RIGHT HAND MOUSE BUTTON. This is known as "right clicking".
15. Select Rename file from the context pop up menu that appears.
16. In the resulting entry box File should be renamed to place the name for your source file. For example:

        		myprogMain

    AND NOTE: you MUST use a different name from the project file name because of peculiarities of Dev-C++.
17. All the stuff that was named "Untitled??" on the desk top should now read "myprogMain"
18. Type your program into the source file editing pane. Here is a small sample you can try for your first program:

        		#include <iostream.h>
        		#include <stdlib.h>

        		void main() {
        			cout << "Hello World\n";
        			system("pause");
        		}

    NOTES:
    - Unlike CC, you must explain that you are going to use the "cin/cout" input output system known as "iostream".
    - Because of the "pause" trick explained below, you must explain that you are going to use a lot of fairly standard stuff named "stdlib".
    - That is what the two #include statements are for. They are NOT algorithm steps, they are more like declaring something (e.g. int x).
    - When Dev-C++ runs your program for you, it opens a DOS box to be the console for your program. As soon as your program finishes, Dev-C++ will destroy that box and so you will not be able to see your program's output.
    - The solution is to make your program pause before finishing. You can see that command above. As a user, you just press the enter key and your program will finish up and the DOS box console will disappear.
19. To Compile and Run your program select the Execute menu and then the Compile and Run item in it. (DUH).
20. "Follow your nose" - i.e. use common sense. For example, it may ask you to save your source file.
21. A progress dialog box will appear to show the progress being made for compiling and linking your program
22. Finally the progress box says Compilation completed.
23. HOWEVER, your program may have syntax errors. To check this:
    - There is a summary pane at the bottom with four tabs. Select the Compiler tab at the left.
    - If the summary pane is empty, then you hopefully have no syntax errors.
    - Later on you may get linker errors - they will appear under the linker tab.
    - If you DO have SYNTAX ERRORS, then you may DOUBLE CLICK on the error line in the summary pane and the corresponding line in the source file panel will be highlighted automatically.
    - In that case, try to fix the mistake, and then compile and run again.
24. Assuming there are no syntax or linker errors, then your program will start and its DOS box console will appear. For the simple program example given above, it will say

        		Hello World
        		Press any key to continue . . .

    where the last line is done by the system("pause") command and you can now just click in the console and press the enter key to finish running your program.
25. NOTE NOTE NOTE
    BEFORE submitting your program to your instructor (or to mentor) remove the system command at the end by "commenting it out":

        		// Press any key to continue . . .

    Because that command may cause the instructor's testing programs to reject your work.

    ## Working on a Program

    Use these steps when you have come back to a program you finished (or quit) earlier.
    1. Start the Dev-C++ application as before by double clicking its icon.
    2. Pick File from the top menu and then Open project or file....
    3. An Open file dialog box then appears.
    4. Find your project file using the dialog box. It should have the same first name as your program's first name (excluding the .exe) and a second name(file extension) of .dev
    5. Proceed as when first creating the program.