March 16, 2010

Final Exam - Part 2

February 25, 2010

There is an issue with reading characters in plain-text mode using an input stream on the Windows platform. When the character with the ASCII code 26 is encountered, the input stream interprets this as an EOF character. This behavior is what causes your programs to only read a part of some PPM images. Unix platforms (including Mac and Linux) do not suffer from this behavior as input streams are opened in binary mode by default. There are several solutions to this problem. One such solution is to open the file in binary mode. Another, less-efficient, solution is to read one character at a time from the PPM file. Since you know ahead of time the size of your raster, you can ensure that all data is read in even though the state of the input stream may change to signal a (premature) EOF. The following code demonstrates how to force the input stream to keep reading after an EOF is encountered:

Assume an input file stream named "in"

long imageSize = width * height * 3;  // The calculated size of the "image" array
char *image = new char[imageSize];    // "image" array
char c;                               // Used in the for-loop. Declared here for scope

for (long i = 0; i < imageSize; i++){ // Iterate over the raster
    c = in.get(); 
    if ( in.eof() ){                  // We just read the character with ASCII code 26
        image[i] = (char) 26;         // Store the value in the image array
        in.clear();                   // Clear the EOF flag and continue reading
        image[i] = c;                 // Assign the value of the character we just read

You are encouraged to read the PPM image data in binary mode, but if you encounter problems, you may use the code above as a last resort.

February 23, 2010

Homework 3 has been postponed to Friday, February 26, 2010 by 12:00PM (Noon!)

February 16, 2010

January 19, 2010

  • Homework 2 has been posted.
  • Lab 1 has been extended to Tuesday, January 26, 2010 - 8:30am.
    • NOTE: The due date/time for Lab 1 is EARLIER than the due date/time of Homework 2!
  • Lectures have been updated.

January 6, 2010

  • Homework 1 has been posted.
  • Links to the in-class examples as well as the Getting Started guide have been posted under the download sections.
  • Links to the audio/video recordings of past lectures have been posted.

January 5, 2010

Welcome to CS332c, Object-Oriented Programming with C++! The class meets on Tuesdays from 8:30am-9:20am (Lecture), and 9:20am-11:50am (Laboratory). The Website may appear bare now, but as the quarter progresses we will add more content to the site

Skype Status


Syllabus pdf

Examples zip

HW3 Example zip

Getting Started pdf


HW1 1/12

HW2 1/29

HW3 2/12


Lab0 due 1/5

Lab1 due 1/26


Midterm 2/9

Final TBD


Tuesday 3/9

Tuesday 3/2

Tuesday 2/23

Tuesday 2/16

Tuesday 2/9

Tuesday 2/2

Tuesday 1/26

Tuesday 1/19

Tuesday 1/12

Tuesday 1/5