Question: First write a function with signature bool interesting(const string & s); interesting's job is to return whether the string passed to it is interesting or

First write a function with signature

bool interesting(const string & s);

interesting's job is to return whether the string passed to it is "interesting" or not.

You decide what the criterion for "interesting" is. (If I were writing this function, I

might define an interesting line as one that contains the chars 'B'. 'O', and 'B' in

sequential order, but you decide what definition of interesting you want to use.)

Your file will read (text mode) from an input file and output to an output file.

Prompt the user, input the name of the input file.

Try to open the input file; c&d (complain and die) if unsuccessful.

Prompt the user, input the name of the output file.

Try to open the output file; c&d if unsuccessful.

Read the lines of the input file; for each line, pass it to interesting to see whether it's

an interesting line. If it is (and only if it is), then write that line to the output file.

So, if none of the lines of the input file is interesting, the output file will have 0 lines.

On the other hand, if every line of the input file is interesting, then the output file

will be a copy of the input file.

Close your files, checking for output errors.

(The idea here is that you can easily change your interesting function to select the

lines you want to copy base on changing criteria.)

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!