Question: Write a C++ program that remove comments from a text file. More specifically, given an input file (input.txt) your program will produce an output file

Write a C++ program that remove comments from a text file. More specifically, given an input file (input.txt) your program will produce an output file (output.txt) which is an exact copy of the input, but does the output does not contain lines for which the first two non-whitespace characters are //. You are not required to remove comments when // characters are after non-whitespace characters.

sample input.txt:

Hello World

// My first comment!

/ This is not really a comment

// This comment is indented!

ABC // This is a comment you do not need to handle

following output:

Hello World

/ This is not really a comment

ABC // This is a comment you do not need to handle

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!