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

  Write a program that asks the user to enter 1000 integers

Write a program that asks the user to enter 1000 integers to be stored in an array called "numbers".

  What combination of a and b will maximize contribution

What combination of A and B will maximize contribution, and what is the maximum possible contribution

  What are the advantages of this architecture

Reduced instruction set computers provide a large number of general-purpose registers and very few memory access instructions. Most instructions use registers instead of memory. What are the benefits of such architecture? Can you think of a disadv..

  Define advantages and disadvantages of wireless networks

I want assitance with question A and question B. Question C has to be in great detail where I can use a a guide to form a comprehensive report. please pr reference will greatly be appreciated.

  Create a trello board for managing your assignment

Create a Trello board for managing your assignment, and maintain the Trello board across the whole assignment process.

  Explain the term wormhole routing at flit level

Explain Wormhole routing at flit level, Virtual channels versus physical channels, Virtual networks and subnetworks and Buffer deadlock versus channel deadlock.

  Using java write a class called temperature

Using JAVA Write a class called Temperature that has two instance variables: a temp value (a floating-point number - data type double) and a character.

  Draw a network diagram

Draw a network diagram representing the following information: the project starts with three activities, A, B, and C, which can be done concurrently.

  Draw a bus structure to perform the operations

Draw a bus structure to perform the operations in problem. A two-bit counter C controls the register transfers shown below.

  Create a microsoft powerpoint presentation on awareness

Create a 6-slide Microsoft PowerPoint presentation on Awareness. Adequate references to support your findings, information, and opinions.

  Questioncreate a scheme for vb mail order to maintain a

questioncreate a scheme for vb mail order to maintain a list of catalogs. utilize a drop-down combo box for

  Explain the formal change management system

The project could fail because the cost of a key component has increased and we could build a product that does not achieve its production cost target.

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