Analyze the code to manipulate the file

Assignment Help Computer Engineering
Reference no: EM132293684

Question: 1. Create a text file and copy this text to it:

Shall I compare thee to a summer's day?

Thou art more lovely and more temperate:

Rough winds do shake the darling buds of May,

And summer's lease hath all too short a date:

Sometime too hot the eye of heaven shines,

And often is his gold complexion dimm'd;

And every fair from fair sometime declines,

By chance, or nature's changing course, untrimm'd;

But thy eternal summer shall not fade

Nor lose possession of that fair thou ow'st;

Nor shall Death brag thou wander'st in his shade,

When in eternal lines to time thou grow'st;

So long as men can breathe or eyes can see,

So long lives this, and this gives life to thee.

2. Add the following code to your Main():

int main() {

std::ifstream in_file {"../poem.txt"};

std::ofstream out_file{"../poem_out.txt"};

if (!in_file) {

std::cerr << "Error opening input file" << std::endl;

return 1;

}

if (!out_file) {

std::cerr << "Error opening output file" << std::endl;

return 1;

}

std::string line{};

while (std::getline(in_file, line))

out_file << line << std::endl;

std::cout << "File copied" << std::endl;

in_file.close();

out_file.close();

return 0;

}

3. Analyze the code, fully understand it, and Change the code to manipulate the file and add a line number to the beginning of each line.

your output should look like this:

1 Shall I compare thee to a summer's day?

2 Thou art more lovely and more temperate:

3 Rough winds do shake the darling buds of May,

4 And summer's lease hath all too short a date:

5 Sometime too hot the eye of heaven shines,

6 And often is his gold complexion dimm'd;

7 And every fair from fair sometime declines,

8 By chance, or nature's changing course, untrimm'd;

9 But thy eternal summer shall not fade

10 Nor lose possession of that fair thou ow'st;

11 Nor shall Death brag thou wander'st in his shade,

12 When in eternal lines to time thou grow'st;

13 So long as men can breathe or eyes can see,

14 So long lives this, and this gives life to thee.

4. Copy your code and paste it here (text input).

Reference no: EM132293684

Questions Cloud

How are the current corporate strategyies working : Create your "improved" mission statement utilizing all components and identify each component in your "improved" mission statement.
Describe and define the scope of the project : Completion of a quality requirements document allows user needs and expectations to be captured, so that infrastructure and information systems can be designed.
Determine the given aspect of the building : General liability will pay for damages if a customer is injured at your apartment complex pool or gym. General liability covers losses to your rental families.
Review the problem related to cyber terrorism : Using the Web or other resources, research an example of Cyber Terrorism. Comment on ways the attack could have been prevented.
Analyze the code to manipulate the file : Analyze the code, fully understand it, and Change the code to manipulate the file and add a line number to the beginning of each line.
Which statement has the clearest vision : What do each of these vision statements suggest about the companies leadership? Which statement has the clearest vision? Why?
How would you determine the optimal board size : How would you determine whether your current board was too big or too small, i.e., how would you determine the optimal board size?
Implications of automation for management in organisations : We are on the cusp of a new age of automation. The rapid strides being made in artificial intelligence (AI) and robotics mean machines
How do stockholders and stakeholders differ : List and discuss the various internal and external stakeholders in your organization. How do stockholders and stakeholders differ?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Calculator python program that prints the menu

Write a simple calculator python program that prints the following menu: 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Quit.

  Will it affect the speedup obtained from pipelining

If a new technology could shortene ALU operation by 25%, will it affect the speedup obtained from pipelining?

  What do you estimate is the bandwidth of a local loop

The telephone line that connects your house or business to the central office carries your conversation. What do you estimate is the bandwidth of a local loop?

  What is the most favorite loop structure

What is the most favorite loop structure. How may you use it in a real business programming problem.

  How can you print three rows of values on an lcd

How can you print three rows of values on an LCD using mbed at the same time for example time, date and year.

  How are ip addresses used for communication purpose

How are IP addresses used for communication purpose over the internet. what are some of the future challenges faced with using IPv6

  Prove that there exists a large set of objects

Suppose that the hash code for your object is defined by some deterministic function h(x; y) that produces a single w-bit integer.

  Write a program that polls users about their dream vacation

Write a program that polls users about their dream vacation. Write a prompt similar to If you could visit one place in the world, where would you go?

  Define a polygon with a maximum of 8 edges

VBA CODE Write a VBA (Visual Basic for Applications) sub program to verify whether a point (with x and y coordinates) lies within a specified irregular polygon.

  Show how the computer would add two floating-point numbers

Show how the computer would add the two floating-point numbers in part a by changing one of the numbers so they are both expressed using the same power of 2.

  When do you think a project team should plan for testing

When do you think a project team should plan for testing? Provide a justification behind your position. Who do you think is the best resource(s).

  Define array type team-record-array with integer components

Define an array type Team_Record_Array with Integer components indexed by Teams. Declare an array variable Win_Loss to be of type Team_Record_Array.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd