CS 2005

Lab 0

Editing, Compiling, Running C++ Programs; Turning in results

Goals
The goals of this lab are to check that you can use the UNIX shell, emacs, and the C++ compiler, g++. This lab also gives you practice in using the turnin program.

What you should do...

  1. Bring up a Unix window. (Your TA will show you how if you are unsure about how to do this.)
  2. Go to your home directory, if you are not already there. You can use the shell command:

    cd ~

    Note the use of the tilde "~" to signify "my home directory".

  3. Make a directory called lab0 in your home directory and make it your working directory. Verify that you have the correct working directory. You can use the shell commands:

    mkdir lab0
    cd lab0
    pwd

  4. Start a script by using the shell command

    script labscript

  5. Copy the file /cs/cs2005/labs/lab0/bubble.cxx to your working directory and verify that the copy is there. You can use the shell commands:

    cp /cs/cs2005/labs/lab0/bubble.cxx .
    ls

    Note the use of the period "." to signify "my working directory".

  6. Use emacs to edit your copy of the file bubble.cxx. As discussed in the pre-lab for Lab 0, you need to add the inner loop to the bubble sort function of bubble.cxx. Save the buffer and exit emacs after you make the changes.

    emacs bubble.cxx


  7. Compile your modified file bubble.cxx using g++. You can use the shell command:

    g++ bubble.cxx


  8. Verify that the program works correctly by typing a.out. If you get an error similar to

    a.out: command not found

    then your PATH variable is set wrong. The easiest solution is to use the command ./a.out
    (which says "run the program a.out in the current working directory").

  9. Exit from the script by typing

    exit

  10. Turn in the modified bubblesort program and your script file. Here is the command you should use:

    /cs/bin/turnin submit cs2005 lab0 bubble.cxx labscript

    This command runs a program which submits your files electronically, so that the TAs can retrieve and grade them. lab0 is the name of the project. The files that you are turning in to lab0 are bubble.cxx and labscript.

  11. You can check for successful turnin by using the command:

    /cs/bin/turnin verify cs2005 lab0


  12. Don't forget to log out. See you next week!


(This lab is a modified version of a lab created by Norman Wittels.)