CSCI 689 Computer Assignment 4 Removing Comments from a Source File

$30.00

Category: Tags: , , , , , You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (2 votes)

Even though comments are essential for human readers, the compiler simply ignores
them. If you are writing a compiler, you therefore need to be able to recognize and
eliminate comments that occur in a source file.
Write a C++ program that copies characters from the input stream to the output
stream except the characters that appear inside C++ comments. Your implementation
should recognize both comment conventions.
 Any text beginning with and ending with possibly many lines later.
 Any text beginning with and ending through the end of the line.
Do not worry about making the layout of the output of your program look nice, and do
not worry about incorrect programs, but beware of and in comments, strings and
character constants.
To compile and link your program with the system library routines, first make a link to
the program and then execute: To test your program, execute:
This command (1) executes your program with the input file
and generates the output file (2) compiles and links the output
file; (3) executes the output program with the input file and
(4) displays the output of the output program in both your terminal screen and
You can find all related files for this computer assignment in directory:
The routine in your program simply calls the following routines for each subtask:
 This routine opens the source file
for the input stream and the source file for the output
stream If either of the file cannot be opened, it calls the function to
handle the error.
 This routine gets the data from the
input stream character by character, and it inserts an individual character in
the output stream if the character is not part of a C++ comment.
 This routine closes both the input and
output source files associated with the streams and at the end of the
program.
 This routine prints the error message on
and exits the program with the nonzero return value
2
When your program is ready, mail its source and header files to your TA by executing the
following command: