Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This program numbers the lines found in a text file. Write a C++ program that reads text from a file and outputs each line to

This program numbers the lines found in a text file. Write a C++ program that reads text from a file and outputs each line to the screen preceded by a line number. Print the line number at the start of the line and right-adjusted in a field of three spaces. Follow the line number with a colon, then one space, then the text of the line. You should get a character at a timeso you will not modify the content. You may assume that the lines are short enough to fit within a line on the screen.

Sample input file:

With three or four loggerheads amongst three or fourscore hogsheads. I have sounded the verybase-string of humility.Sirrah, I am sworn brotherto a leash of drawers; and can call them all bytheir christen names, as Tom, Dick, and Francis.They take it already upon their salvation, thatthough I be but the prince of Wales, yet I am kingofcourtesy; and tell me flatly I am no proud Jack,like Falstaff, but a Corinthian, a lad of mettle, agood boy, by the Lord, so they call me, and when Iam king of England, I shall command all the goodlads in Eastcheap.

Sample screen output:

1: With three or four loggerheads amongst three or four

2: score hogsheads. I have sounded the very

3: base-string of humility.Sirrah, I am sworn brother

4: to a leash of drawers; and can call them all by

5: their christen names, as Tom, Dick, and Francis.

6: They take it already upon their salvation, that

7: though I be butthe prince of Wales, yet I am king

8: ofcourtesy; and tell me flatly I am no proud Jack,

9: like Falstaff, but a Corinthian, a lad of mettle, a

10: good boy, by the Lord, so they call me, and when I

11: am king of England, I shall command all the good

12: lads in Eastcheap.

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_2

Step: 3

blur-text-image_3

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

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions

Question

3. How would you address the problems that make up the situation?

Answered: 1 week ago

Question

2. What recommendations will you make to the city council?

Answered: 1 week ago