CS1005, Lab 1

January 15, 2003

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

Reminders:
You must leave the leave the lab promptly at 50 minutes past the hour. You must attend the lab section for which you are registered - NO EXCEPTIONS.

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

Lab Steps

  1. Sign the attendance sheet so you will get credit for this lab.
  2. Log on to the computer (the TA will help you if you don't know how). 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. Start a script by using the shell command

    script labscript

  4. Make a directory called cs1005 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 cs1005
    cd cs1005
    pwd

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

    cp /cs/cs1005/labs/lab1/lab1.cxx .
    ls

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

  6. Use emacs to edit your copy of the file lab1.cxx. You should change the comments at the beginning of the program as indicated. Save the buffer after you make the changes. (You can use this shell command to start the emacs editor in the background :

    emacs lab1.cxx &

    Note the use of the ampersand "&" to signify "run this in the background".)

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

    g++ -Wall lab1.cxx


    There are some compilation errors in the program. Try to find and fix the errors (ask a TA for help if you get stuck). Re-compile the program. Don't proceed to the next step until the program compiles successfully.

  8. The program calculates the gross pay for an employee, given the hourly wage and the number of hours worked. 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

    Examine the scriptfile by typing

    more labscript

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

    /cs/bin/turnin submit cs1005 lab1 lab1.cxx labscript

    This command runs a program which submits your files electronically, so that the TAs can retrieve and grade them.

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

    /cs/bin/turnin cs1005 verify lab1



Cleanup
Don't forget to quit emacs and rm (remove) any files you don't need in your home directory. Then logout. This is very important to speed up the login for the next group and to make sure nobody else has access to your home directory.


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