Assignment 1, due Thursday January 27 at noon.

You must submit your program electronically via gsubmit on csa.

Under no circumstances will late assignments be accepted.

The code you submit must conform with the programming guidelines.


Program Description

Write and submit one program called filter.cpp.

The program reads a stream of characters from standard input. It writes the same stream of characters to standard output, with all C++ comments removed.

Your program should not remove new-line characters unless they appear within a multi-line comment. This means that your program must preserve new-line charaters in all other cases.

You should be careful to only remove valid comments, as defined by standard C++ comment syntax rules.

Your program should properly handle line comments:

int i; // this is a line comment

Your program should properly handle multi-line comments:

/* this is a
multi-line
comment */

Your program should properly ignore comment delimiters that appear within quotes:

" this is a comment delimiter within a /* quote "

Final note: when '\"' appears within a quote, it does not close the quote.


Program Wrapper

To help you get started, we have prepared a program wrapper:

filter.cpp

You can copy and modify this wrapper, filling in the missing pieces needed to complete the assignment. Please read the file header for more information.

You are responsible for thoroughly testing your program to make sure that it works. In grading your program, we will test your program on some standard test files. To help you get started, here is one test file:

testfile.cpp

and here is the correct, filtered output:

outfile.cpp

You should compare your output with this file to make sure it matches. You should also generate your own test files. Use them to test your program further, however do not submit your test files.

Grading Criteria

Refer to the grading criteria file: p1.criteria


Academic Honesty and Collaboration

Cooperation is recommended in understanding various concepts and system features. But the actual solution of the assignments, the programming and debugging must be your individual work, except for what you specifically credit to other sources. (Your grade will be based on your own contribution.) For example, copying without attribution any part of someone else's program is plagiarism, even if you modify it and even if the source is a textbook. The University takes acts of cheating and plagiarism very seriously: first time violators are routinely suspended for a semester.