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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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