Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Teacher's Instructions In each progject, you should open the files using any paths to folders but remember that on a Windows system, you must use

Teacher's Instructions

In each progject, you should open the files using any paths to folders but remember that on a Windows system, you must use the '\' character when specifying directories. If you copy the input file to the same directory as your project executible, you can simply open statements using the following:

cin >> filename; // where the user enters "hw4pr1input.txt"

inputFileStream.open(filename);

That means the input and output files need to be in the same folder as your compiled and linked executable code (your EXE file). That will vary by compiler, but it is not difficult to place your files in the correct folder. I don't want to see paths to folders on your computer, those paths will not work on mine when I go to grade your homework. If I have to modify your open statements or if I have to answer prompts for file names I will count off.

This solution simply opens and iterates through the text file of names until a match is found. It could be improved by making case-insensitive matches.

Text Book Question

Write a C++program that will correct a C++ program that has errors in which operator, << or >>, it uses with cin and cout. The program replaces each (incorrect) occurrence of

cin << with the corrected version cin >>

and each (incorrect) occurrence of cout >> with the corrected version cout <<

Allow for the possibility that there may be any number of whitespace characters (one or more) between cin and << and between cout and >>. The replacement corrected version has only one blank between the cin or cout and the following operator.

Your program should get the source filename as an input from the user. The corrected version should be output to a file with name corrected.txt and it should also be displayed on the terminal. That means output of your program (after getting the filename) should be exactly same as the contents of the file corrected.txt. Your program should define a function that is called with the input- and output-file streams as arguments. (File name babynames2012.txt)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions

Question

using signal flow graph

Answered: 1 week ago

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago