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...


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 function


 void remove Comments (istream & is, ostream & os);


that copies characters from the input stream is to the output stream os, except for 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 extending through the end of the line. The real C++ compiler needs to check to make sure that these characters are not contained inside quoted strings, but you should feel free to ignore that detail. The problem is tricky enough as it stands.

Nov 18, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here