Introduction to Unix and C++

CS 210 In-Lab 1
January 21, 2004
To do this assignment, you should be signed onto your esus account. Your TA will explain at the beginning of class how he wants you to submit your materials to him.

Purpose
The purpose of this lab is to make sure that everyone can:

  1. Get up and running using your account on the Linux operating sytstem on a computer in EPS254,
  2. Answer questions about the use of basic Linux (or Unix) commands.
  3. Use an text editor (emacs, vi, or pico) on Linux.
  4. Write and compile a simple C++ program.

What to do

  1. To begin:
  2. First, you will experient with text editors, and decide which one you want to use.
  3. Next, you will run a Unix tutorial, then answer some questions, and experiment with Unix.
  4. Finally, you will use the text editor to write a simple C++ program, compile it, then run it.

Text Editors
Unix has several text editors you may use. The simplest to use is probably pico but emacs and vi are more powerful, although may take longer to learn to use. Start up the editor of your choice, and use the help feature to learn to use it.

You will use the editor later in the assignment, first to answer some questions, then to write a simple C++ program.

Unix
There are many Unix tutorials available on the World Wide Web. Go to this one, bookmark it, and then take some time to see what is available, then read at least the first two sections and then answer the following questions.

  1. Type ls. What happens and why?
  2. How is ls -l different than simply ls?
  3. Explain how to make a directory called cs210. (Do it.)
  4. Explain how to make cs210 your working directory. (Do it.)
  5. From your cs210 directory, describe three separate ways to go back to your home directory.
  6. From your cs210 directory, show the exact directory structure from the root of esus to your 210 directory.
  7. Navigate our Unix system enough to estimate the number of students with esus accounts. Explain how you derived your estimate.

Write, compile and run a C++ program

  1. When you have completed the above exercises, go to your cs210 directory and create a subdirectory called inlab1.
  2. Go to the inlab1 subdirectory and use a text editor to create a file called lab1.cpp. Write a C++ program that prompts the user for the width, height, and depth of a box and then prints out its volume. Assume that all numbers are integers. A sample run is shown below.
      Box volume program.
    
      Enter the width of the box: 2
      Enter the height of the box: 3
      Enter the depth of the box: 4
    
      The volume of the box is 24.
  3. Compile your program by typing g++ lab1.cpp
  4. Run your program by typing a.out.

Using Vectors and File I/O

CS 210 Lab 2
January 28, 2004

Lab due in one week: at the beginning of lab February 4, 2002

Working with Linked Lists

CS 210 Lab 3
February 4, 2004

Lab due in one week: at the beginning of lab February 11, 2004

Working with Arrays

CS 210 Lab 4
February 11, 2004

Lab due in two weeks: at the beginning of lab February 25, 2004

Design, implement and test a fraction class

The driver (client) of your Fraction class

Extra Credit

Design and implement a phone & address book

Using a Debugger

Due date:
This is a one week lab.: It is due at the beginning of lab on April 7, 2004
You will be asked to show that the little program given in this lab works correctly. You can do that either this week, or at the beginning of lab next week. You should use the debugger to find and correct the errors.

Objectives and Guidelines:

  1. Runtime errors are notoriously hard to find. A debugger can help you with this
  2. This lab has two parts: learn about GDB, the GNU debugger, and use the debugger.

Learn how to use GDB
There are at least two sources for you to learn to use the debugger:

  1. The GDB users manual
  2. The help feature within the debugger itself
  3. You could also do a search on the web to see if you find information more to your liking.
With the debugger manual:

Use GDB
As you work with the debugger, use the GDB manual and the help feature to answer the questions below.

Questions to answer
Copy these questions into a text editor, then as you find the answers type them in. You will find the answers in eithe the debugger manual or using the help function within gdb or both.

  1. If you want to debug a file named "myErrors.cpp", what do you type to compile it so it can bedugged?
  2. What do you type to start the debugger on the file above?
  3. What are breakpoints?
  4. How can breakpoints be set?
  5. How can you ask the debugger to let you know the value of variables?
  6. What is the difference between "next" and "step"?
  7. What does the list command do?
  8. What happens if you press "Enter" without entering a command?
  9. What does the info command do?
  10. What is a watchpoint?
  11. How do you delete breakpoints?
  12. What interesting feature(s) have you found that are not mentioned here?
  13. How do you exit gdb?

Write a Thesaurus

Last lab

What to do
  1. Fill out a course and instructor evaluation.
    • This semester we are using an on-line evaluation system. Click on the link above, and follow directions. The instructor evaluation is separate from the course evaluation; there is a link to it after you submit the course evaluation.
    • . We would like to have 100% of the students fill out the form. It can really help us improve the course in the future, as well as helping the instructor know what students think they do well, and what could be improved.
  2. Demo and/or hand in the last lab.