Dev-C++ Setup Instructions

MCX1 home     MCX2 home     Setting up the AP classes      Marine Biology program    Visual C++: C++ strings


1. New improved Dev-C++ setup instructions:
a. Setting up from the InstallC++ directory on the CD handout or on your hard drive
    (If you don't have the CD, use the InstallC++ directory that you copied to your hard drive)
1. Insert CD in drive
2. With Windows Explorer
   a. Select the CD drive
   b. Click on the InstallC++ folder
   c. Click on the devcpp4.zip folder. This opens a compressed folder.
   d. Click on SETUP.EXE in the compressed folder.
   e. This completes the Dev-C++ installation to the C:\Dev-C++ directory.
3. Go back to the root of the CD.
    a. Copy the 90-APclasses folder to the C:\Dev-C++ directory.
    b. Do the same with the other folders (at your convenience)
4. Complete the installation of the AP classes by going to:
   Setting up Dev-C++ for the AP classes
5. Instructions for short Dev-C++ programs:
Building Simple Dev-C++ Programs
6. Additional files on CD: ws_ftple.exe, netzero.exe, MCX1 (folder), emacs-19.34

b. Compiler options: Setting up AP classes and turning on all warnings (new instructions!!)


Building Simple Dev-C++ Programs

1. After installing Dev-C++, click on the Dev-C++ icon to bring up its integrated  programming environment.
2. From the top menu bar, select the
File pulldown menu.
3. From File pulldown menu, select New Source file.
4. Selecting
New Source file automatically generates this skeleton source program:

Untitled1                                                                                         

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

int main()  {

    system("PAUSE");
    return 0;
}

4a. Two things are worth noting about this code. First, the system("PAUSE") statement
       prevents the program from terminating and vanishing from the screen before its 
       output can be read. In order for the compiler to recognize the system statement,  
       stdlib.h must be #included. Incidentally, the "PAUSE" parameter is unique to Dec-C++.
4b.  Every Dev-C++ main function must return an int. Although a void main is a part of
       standard C++, Dev-C++ doesn't support it.  
5. Add the appropriate program statements to achieve your programming objective.
6. To save the Untitled file to a suitable file name in a suitable directory:
    From the File pulldown menu on the top menu bar, select Save unit.
   
(The shortcut for the command sequence above is CTRL-S)
7. To execute the program:
     From the Execute pulldown menu on the top menu bar, select Compile and Run.
     (The shortcut for the command sequence above is CTRL-F10)


Setting Up Dev-C++ for the AP classes

1. Copy the 90-APclasses directory (from the CD's MCX1  or Dev-C++ folder, depending on your CD).
2. From the top menu bar, bring up the
Options pulldown menu and select Compiler options.
3. Selecting Compiler options displays the Compiler options window. Select the Directories tab if
    the window that appears differs from the one represented below.

Compiler options                                                                                                   
Directories C/C++Compiler Code Generation Linker  

Add the directory below to be searched for include file:
    
____________________________________________                
Add the following commands when calling the compiler:
    
____________________________________________                


Bin directory:          C:\DEV-C++\Bin\                                                           

C include files:        C:\DEV-C++\Include\                                                     

C++ include files:   C:\DEV-C++\Include\G++;C:\DEV-C++\Include\        

Libraries directory: C:\DEV-C++\Lib\                                                           
   

Ö OK X  Cancel ? Help     ¬  Default

4. Click the   Add the directory below to be searched for include files: box and enter C:\DEV-C++\90-APclasses\
    in the space provided below.
5. Click the   Add the following commands when calling the compiler: box and enter
    -Wall C:\DEV-C++\90-APclasses\apstring.cpp in the space provided below.
    a. -Wall instructs the compiler to issue warnings when the use of the C++ program language is grammatical
        but possibly unwise. Example: assigning a floating point value to an int variable.
    b. C:\DEV-C++\90-APclasses\apstring.cpp   instructs the compiler to translate the apstring.cpp file in addition
        to the current file. While the translation won't be necessary in programs that don't use apstrings, it won't do any
        harm. And this arrangement enables the programmer to employ the apstring class the same way he or she |
        employs the other AP classes.       
6. Click the OK button. You're now able to use all the AP classes in your Dev-C++ programs. The
    sample program below, which uses the apstring and apvector classes, should compile and execute.

Untitled1                                                                                         

#include <iostream.h>
#include <stdlib.h>
#include "apvector.h"
#include "apstring.h"

int main()
{
    apstring st("Hello Goodbye");
    apvector<double> v(10);
    cout << "apstring object st = " << st << endl << endl;
    for (int n = 0; n < 10; n++) {
          v[n] = 2*n + 1;
          cout << v[n] << "   ";
    }
    cout << endl << endl;
    system("PAUSE");
    return 0;

}



Building the Marine Biology Case Study Program with Dev-C++


1. Before starting, make sure you have two directories of the Marine Biology case study files. In the
    hand-out disk, one was named 91-APmarine. Use Windows Explorer to copy and paste this directory to a
    second (backup) directory.

2. Start up Dev-C++ and:
    a. From the Top menu, select File and click on the  91-APmarine directory when Dev-C++ responds
        by listing the directories and files in Dev-C++ directory.
    b. Once in the 91-APmarine directory, click on Cancel
    c. Now select  File from the top menu again, but this time select New Project. Then select Console
        Application
when the resulting menu comes up.
    d. After you select Console Application, you'll be prompted to enter a name for the project. Enter
        MBCS or whatever you want to call the project. The ensuing prompt will give you the opportunity
        to save the project file to the name that Dev-C++ provides or to an alternate name that you enter.
       
3. After saving the project file, a project file tree will be displayed on the left panel of the Dev-C++
    screen, the root being the project name and the child being a file named Untitled1.
    a. Right-click on Untitled1 and select Remove from project from the resulting menu.
        When you're asked if you want to save changes to Untitled1, respond No.

4. Now you're going to add the case study's nine cpp files to the project. (The order
    in which you add them shouldn't matter.)
    a. Right-click on the root (which is labelled with the name you gave the project) and
        select Add to project. From the file listing that follows, select fishsim.cpp by
        double-clicking or selecting Open.
    b. Repeat the process above for the eight remaining cpp files:
        1. display.cpp                 5. position.cpp
        2. environ.cpp                 6. randgen.cpp
        3. fish.cpp                       7. simulate.cpp
        4. nbrhood.cpp                8. utils.cpp
    c. To compile and link the project, choose Execute from the top menu followed by
        Compile and Run (just as you did without projects).

5. Other commands:
     a. File/Close Project: Closes all nine cpp project files.
     b. Execute/Rebuild all:  Ensures that modifications to project are re-compiled.
     c. File/Open project or file: For all your following sessions with the project, select the project file
         and let Dev-C++ bring all the files together for you!

Visual C++: strings and apstring (by Chris Russo's example)

#include <iostream.h>
#include <string>
using namespace std;  // This directive should follow the includes

int main() {
   string st("Hello");
   cout << st.c_str() << endl;  // instead of st, cout needs st.c_str()
  
// This alternative might or might not work: cout << string::st << endl;   
  
return 0;
}

// For the apstring class, apstring.cpp must be added to the project and <apstring.h> must be included
// instead of <string>. The installer for  Visual C++ sets up the other classes for you.

MCX1 home     MCX2 home