DCO20105  Data Structures and Algorithms

Semester A, 2002-3

 

Lab 1 -- Getting familiar with the environment

Objectives:

 

Laboratory Exercise

  1. Go to the course page: personal.cityu.edu.hk/~dcrosela and browse through this page.  List the information you can get from this page and things missing.  The things missing will be added bit by bit.  Note that all student notices will be sent to you through e-mail and also posted on the course page in case you run out of your disk quota or accidentally delete the message. 

  2. Get into the Cygwin: Click the icon Cygwin from the desktop.

  3. Read Configure Cygwin.

  4. Set necessary environment variables for implementation of SSD5 programs:

    1. Outside Cygwin, find where the cygwin.bat is and take a look on it. You may change the its contents as described in 3, exit from Cygwin (type exit, may be twice) and start Cygwin again.

      At home, once you change the configuration file cygwin.bat as described in 3 on your computer, you don't need to take care of the above two environment variables.  However, the lab rooms may not set these variables correctly for your usage.  You may need to change cygwin.bat everytime before starting Cygwin in lab rooms since they don't keep your changes.  Another way is to the following two steps inside Cygwin.

    2. Check the values of the current environment variables:

                        echo $PATH
                        echo $HOME

      Note that PATH and HOME are all capital letters.

      Check if the values of $PATH include your current directory "./" and if $HOME is set to your working directory.  You may need to use the command mount to know the file name under Windows.

    3. Set the proper values for the environment variables:

                        export PATH=PATH:./
                        echo $PATH

  5. Read Some system environment background.

  6. Download sample programs to your working directory/folder.
  7. Read Frequently used simple Unix commands and try to do the following
    1. Check your current working directory:  pwd.
    2. If that is not the one you want, change it to your specific directory:  cd MyFolderWithPath.
    3. List the files with different options: ls [-l] [-a]
    4. View a text file: cat myprog.cc
    5. View a text file: less myprog.cc
    6. Get help for different commands: man [command]

  8. Read Introduction to vim and try to use vim to create and edit a file. 

  9. Read Compile and execute a simple program. Then compile and execute a simple program:


    g++ -o myprog myprog.c

    myprog

  10. Compile and run simple programs with arguments.

    g++ -o cmdline.cc
    a                        (Should have error message)
    a first second third
    g++ word-count.cc
    a                        (Should have error message)
    a word-count.cc
    a cmdline.cc

    myprog

  11. Compile a program which has errors.

    g++ errprog.c

    Read the message carefully and try to understand the message.  Then correct the error and make it run.

    Note: You may compare this program with myprog.cc in case you cannot correct it.

  12. See what the preprocess does.

    g++ -E myprog.cc > myprog.e1
    g++ -DDEBUG -E myprog.cc > myprog.e2


  13. Before you leave the lab room, remember to type exit to quit the Cygwin.


Marking

4 to 1 -- awarded according to the completeness of working the lab exercises.
0 -- absent (without extenuating circumstance) or no participation at all.

 


Copyright © 2002 Rossella KH Lau
Last modified: August 30, 2002