CMSC 202 Spring 2003
Lab Assignment 1

Purpose

This lab will serve as an introduction to the CMSC 202 lab environment. You will also be introduced to editting, compiling, linking and executing C++ programs in this laboratory setting.

The Assignment

  1. Logon on to your GL account.
  2. Edit your .cshrc file to create an alias for g++
  3. Copy the file /afs/umbc.edu/users/d/e/dennis/pub/.emacs to your home directory.
    This file is used by the emacs editor to automatically indent code according to our coding standards.
  4. Under your home directory, create a directory called "cs202".
  5. Under your cs202 directory, create a directory called "labs"
  6. Under you labs directory, create a directory called "lab1". All work for this lab should done in the lab1 directory

  7. Using the editor of your choice (preferably emacs or vi), create the file HelloWorld.C exactly as shown below. <!--#include virtual="HelloWorld.C"-->
  8. Compile HelloWorld.C and create the executable HelloWorld by using the command
        g++ -ansi -Wall -o HelloWorld HelloWorld.C
  9. Execute the program
  10. Edit HelloWorld.C in each of the following ways to view common g++ error messages. After editting, compile your program with the command g++ -ansi -Wall -o HelloWorld HelloWorld.C >& error10X, where X is an item label listed below (e.g error10A). This command redirects your compiler errors to the file error10A. View the error file using the unix command "less". Be sure you understand what the error means and why it was caused. If you're not sure, ask someone. Fix each error by undoing the edit before continuing to the next edit.
    1. Remove the // at the beginning of line 9
    2. Remove line 13 (#include <string>)
    3. Remove the word "int" before "main on line 17
    4. Remove the ending quote after "Hello" on line 19
    5. Remove line 20 (string world ("world");)
    6. Remove line 25 (return 0;)

  11. After completing all edits and creating all error files, have your TA verify your work so that you recieve credit for today's lab.