810-062-01
CS II
Spring 2007
Last updated Mar 29, 2007
Instructor: Dr. O'Kane
Office: 318 ITT (East Gym)
e-mail: okane@cs.uni.edu
www http://www.cs.uni.edu/~okane
Tel 273-7322
Office Hours: Click Here
Emailing assignments
To email an assignment:

1.  the source code must have in a comment block
    at the beginning your name, class time,
    your email address where replies are to be sent,
    assignment number, assignment description:

    /* Joe Smith, MWF 10, smith@gmail.com
       assignment 1: reading in and manipulating data */

2.  use the script program to make a transcript of
    your screen session.  In cygwin, you will need
    to install the script program - previously emailed.
    On neamh, script is already there.

    script
    cat myprog.c
    gcc myprog.c
    ./a.out  (neamh only)
    ./a      (cygwin only)
    exit   (or ^d)

    You now should have a file named typescript.  Look it over
    and if its ready to send, send.  Otherwise, repeat the above.

3.  From neamh:

mail -s "Joe Smith Asgn 1" -c smith@gmail.com uni036061@xxxxxx < typescript

The qouted part should give your name and a description.  The smith@gmail.com
is your email address, the uni036061@xxxxxxx is my email address and
typescript is what you are sending.  Note the "<" sign.

In the above, substitue earthlink.net for xxxxxxx

4.  From Cygwin, you need to use your system's email program.  Send the file
    in c:\cygwin\home\youruserid\typescript as an attachment to
    uni036061@aol.com and place in the subject line, who you are and
    the assignment number.

It is important that you include your actual name as email id's are not
enough.  I will send a confirmation and a grade.
script for Cygwin Here is a compressed tar-ball of the script program for Cygwin. To use:

1. save it to your cygwin home directory.

    -> finding your home directory:

        enter cygwin
        type pwd

        you will see something like /home/user
        where the "user" part may be different.

        your home directory, from MS Windows point of view
        is then:  c:\cygwin\home\user

        save it to this directory.

2. enter cygwin and decompress/un-tar it:

    it should be in your home directory (do an ls and see
        if you have the file script.tgz.

    type:

    tar xvzf script.tgz

    this creates a subdirectory named script.

3. enter the subdirectory script:

    cd script

4. compile it:

    gcc -o script Script.c

    (you will get two info messages - ignore these)

5. copy it to the executables directory:

    cp script /usr/bin

it should now work by typing script (type ^d or exit to end)
Book: Remember to check prices online where both new and used copies may be available at discount. Also, be certain to check the title exactly. There are other texts with similar titles by the same authors.

C - How To Program - Fourth Edition, Deitel & Deitel, ISBN 0-13-142644-3, Pearson Prentice Hall.

Requirements:
  • 8 (approx.) assignments counting a total of 40 percent, 5 points per class day penalty if late;
  • Two tests each counting 15 percent for a total of 30 percent;
  • Lab Project counting 10 percent - project statements due Feb 15;
  • A final exam counting 20 percent;
  • Attendance is required. A grade penalty of up to one letter grade will be imposed for excessive unexcused absence. The term "excessive" means don't push your luck.
Makeup Tests Makeup tests will be given only in cases of demonstrated need for causes such as serious illness, family emergency or University sanctioned schedule conflict. In all cases, written documentation will be required.
Test dates:
  • Mon Feb 19
  • Fri Mar 23
  • Final: TBA
  • Final Grades Final grades will not be available via email. If you want your grade mailed to you, bring a stamped, self-addressed envelope to the final.
    Originality If your work duplicates in whole or in part the work of someone else, both works will receive a grade of 0.
    Topics:
  • Objects
  • Classes
  • Vectors and matrices
  • File systems
  • Data structures
  • Inheritance and polymorphism
  • Multi-dimensional arrays
  • Library Functions
  • Threads
  • Bash Tutorial
  • Advanced Bash-Scripting Guide
  • Bash by example
  • Bash by example part 2
  • Bash by example part 3
  • Lab Project Part of your grade will be based on a project. If there is something you are interested in that you would like to do, and this may be related to another class, write a short description and send it to me.

    By Feb 15, I need a one sheet statement of what you want to do for a project (the "lab" credit - this is a 3 hour lecture and 1 hour lab credit course). The project should be something that applies C/C++ to some area. If you have nothing in mind, see me and I have some topics. Otherwise, I will assign one.

    Due: Last day of class.

    Notes const usage
    Homework Spring 2007 All assignments must have your name and the assignment number in a comment header block. All pages must be stapled. Turn in a copy of the source code, the output and (if any) the input. Non-functional programs will not receive a grade higher than 70%. Programs with no output or comment header block will be returned ungraded.

    You may do your assignments on any machine with a C++ compiler. This includes any machine you may have, the lab machines or sidhe.cs.uni.edu. If you do your work on sidhe.cs.uni.edu, you need to print the results on another machine as sidhe.cs.uni.edu has no printer. (see below).

    1. Write a class to handle strings. As there is a C++ class called 'string', use another name such as String (uppercase). Your class should be based on a char * pointer and an array of char's will be allocated and its address placed in this pointer. As strings grow, de-allocate the old small string and allocate a new, bigger one. Maintain a private integer that tells you how long the string you allocated is.

      Overload the assignment, and comparison operators to permit String to String assignment and comparison and String to null terminated char array assignment and comparison (assign a char * string to a String only). Overload the + operator to concatenate two strings. Include a function that returns string length. You also need a destructor as well as a constructor. Due: Fri Feb 2.

    2. Write the skeletal class definitions (with inheritance information) but no functions for the following scenario:

      The underlying concept is Media. There are instances of Audio Media, Book Media, Video Media, Periodical Media. Audio Media has instances of CD's, Tapes, REcords, MP3. Visual Media has instances of Video Tape, DVD's, and Broadcast. Periodical Media has instances of Magazines, Newspapers, Journals and Newsletters.

      Include a class hierarchy diagram. Due: Mon Feb 12.

    3. Do exercise 21.17 on page 805. Due: Fri Mar 2.

    4. Write a program that reads in data of the form:

      Jones, John          123-4567
      Smith, Mary          555-1234
      

      where the name is in the first 25 characters and the phone number is in the remaining 7 chararacters.

      The program will load each line of data into a structure then write the structure to a disk file. The program will maintain an array of character pointers. Each pointer will point to a string containing a phone number. The strings containing the phone number will be allocated as the numbers are read in and the pointer to the allocated string will be placed in an array of char pointers. In a corresponding array of long integers, place the file offset address of the record written associated with the phone number.

      At the end of the input, print a list of the phone numbers and the file offsets of the corresponding numbers. Due: Fri Mar 23.

    5. Using pipe() and fork(), write a program which opens a pipe, forks, then, in the parent process, reads lines from a file and sends them to the child process which prints them. Due: Fri April 6.

      NOTE: All homework is due by 3 pm April 27. Nothing will be accepted after that date.

    Misc
    How to prepare homework: If you are using a Linux host, you can prepare a file containing your program and its output bu using the program "script". Script makes a transcript of all your activities at the terminal. To use it, do the following:

    First, type the command:

    script

    and you will see the reply:

    "Script started, file is typescript".

    Now everything you type and everything you see on the scren is being recorded in a file named "typescript".

    Next display your program:

    cat myprog.cpp

    (fill in the name of your program). Next compile it:

    g++ -o myprog myprog.cpp

    Next run it:

    myprog

    and type input as needed. When done, type ^d (control-d). This will terminate the file typescript. Now you need to print typescript. See the section below on printing using CNS printers.

    If you are working at home and want to print using your home printer, you need to copy typescript to your home machine. From Windows, this can be done with the program "pscp" which you can get at the same site that has "putty". To use it from a home machine, bring up a Windows command window, move to a suitable directory and type:

    pscp yourname@student.cns.uni.edu:dir/typescript .

    You will be prompted for password. Note, the expression ":dir/typescript" means that your typescript file is in your subdirectory "dir" relative to your home directory (the one you land in when you logon).

    If you do your work on neamh, you need to copy it to a CNS machine or home. If copying to home, use the above but subsitute "neamh.cns.uni.edu" (without quotes) for "student.cns.uni.edu". To copy to a CNS machine, login to the CNS network, move to a suitable directory and type:

    scp yourname@neamh.cns.uni.edu:dir/typescript .

    (Note: scp, not pscp). Then follow the printing instructions below.

    PUTTY/PSCP for WindowsClick Here
    C/C++ References and Links Links to on-line help and free compilers
    Cygwin for Windows Click Here
    vi Editor Introduction to display editing with VI
    VI lovers home page
    Mastering the VI editor
    The VI/EX editor
    VI Tutorial
    Vi Key chart
    Linux Tutorials UNIX Tutorial for Beginners

    UNIX Tutorial

    Unix Command Summary

    Quick Unix Tutorial

    The Basic Shells

    Norman Matloff's Unix and Linux Tutorial Center

    Notes
    1. How to print.

      If you are logged on to one of the linux systems in the Wright Hall labs, type:

      lpr -Pwrt112 filename

      or

      lpr -Pwrt339 filename

      where "filename" is the file you want to print. The file will be printed in either Wrt 112 or Wrt 339.

      Other print commands:

      Show me the print queue for wrt112: lpq -Pwrt112

      Remove jobnumber from the wrt112 queue: lprm -Pwrt112 jobnumber

    2. To make a transcript file that you can print, logon to chaos or one of the linux boxes. Move to the correct directory. Type:

      script

      From now on everything you type and everything that appears on your screen will be copied to a transcript file. To make a file to turn an assignment in:

      cat myfilename.cpp
      g++ myfilename.cpp
      a.out

      When you are done, type control-D (hold the control (ctrl) key and hit the d key. This will terminate the script session and you will have a file named transcript that contains a record of what you did. You can print this.

    Labs CNS Computing Facilities
    UNI's Witness Protection Program

    April 2007

    Note: only known instance with all of their mouths shut.

    May 2006

    Note the happy, satisfied looks.

    -->

    The following notice is required by the University:

    "The Americans with Disabilities Act of 1990 (ADA) provides protection from illegal discrimination for qualified individuals with disabilities. Students requesting instructional accommodations due to disabilities must arrange for such accommodation through the Office of Disability Services. The ODS is located at: 213 Student Services Center, and the phone number is: 273-2676."

    Because the Office of Disability Services has procedures in place to determine the validity of disability claims as well as the need for instructional accommodations, faculty are reminded that they are to direct all students with accommodation requests to the above listed office.

    UNDER NO CIRCUMSTANCE SHOULD A FACULTY MEMBER MAKE AN ACCOMMODATION INDEPENDENT OF THE OFFICE OF DISABILITY SERVICES.

    Questions may be directed to: Jane Slykhuis, Disability Services Coordinator, at 273-2676 or to this office at 273-2846.

    Kevin C. O'Kane / Computer Science Department / UNI / okane@cs.uni.edu

    Access count: