Write a c++ program that collects from the user(keyboard) the first few lines of Hamlet.  Inputting text lines into the program should use cin.getline( …..) function. The program should contain the following parts:  an  array of char pointers *ptr[15] – there are more char pointers than text lines  declare a temporary char pointer (*tmp)  declare a char Phrase[120] which is used to store temporarily each input line of Hamlet  each new line of text  is stored in Phrase and should be copied onto the heap and its memory location assigned sequentially to ptr[i].  Recall that you must allocate memory on the heap via new memory function.  after collecting all lines of text – print all input text lines (track # of input lines with int LineCnt)  change each uppercase letter to lowercase on the entire text Hamlet  print all text lines containing a punctuation symbol(; , . ?)  print all text lines that contain the letter ‘d’  copy line #10 to the end and print  again all text lines  compress the modified text lines so that one does not see the old line #10    Hamlet’s Soliloquy   To be or not to be, that is the question  Whether 'tis nobler in the mind to suffer  The slings and arrows of outrageous fortune,  Or to take arms against a sea of troubles  And by opposing end them. To die—to sleep,  No more; and by a sleep to say we end  The heart-ache and the thousand natural shocks  That flesh is heir to: 'tis a consummation  Devoutly to be wish'd. To die, to sleep;  To sleep, perchance to dream—ay, there's the rub:  For in that sleep of death what dreams may come,  When we have shuffled off this mortal coil,  Must give us pause—there's the respect  That makes calamity of so long life.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter10: Pointers
Section10.3: Pointer Arithmetic
Problem 5E
icon
Related questions
Question
  1.  Write a c++ program that collects from the user(keyboard) the first few lines of Hamlet.  Inputting text lines into the program should use cin.getline( …..) function. The program should contain the following parts: 
  • an  array of char pointers *ptr[15] – there are more char pointers than text lines 
  • declare a temporary char pointer (*tmp) 
  • declare a char Phrase[120] which is used to store temporarily each input line of Hamlet 
  • each new line of text  is stored in Phrase and should be copied onto the heap and its memory location assigned sequentially to ptr[i].  Recall that you must allocate memory on the heap via new memory function. 
  • after collecting all lines of text – print all input text lines (track # of input lines with int LineCnt) 
  • change each uppercase letter to lowercase on the entire text Hamlet 
  • print all text lines containing a punctuation symbol(; , . ?) 
  • print all text lines that contain the letter ‘d’ 
  • copy line #10 to the end and print  again all text lines 
  • compress the modified text lines so that one does not see the old line #10 

 

Hamlet’s Soliloquy  

To be or not to be, that is the question 

Whether 'tis nobler in the mind to suffer 

The slings and arrows of outrageous fortune, 

Or to take arms against a sea of troubles 

And by opposing end them. To die—to sleep, 

No more; and by a sleep to say we end 

The heart-ache and the thousand natural shocks 

That flesh is heir to: 'tis a consummation 

Devoutly to be wish'd. To die, to sleep; 

To sleep, perchance to dream—ay, there's the rub: 

For in that sleep of death what dreams may come, 

When we have shuffled off this mortal coil, 

Must give us pause—there's the respect 

That makes calamity of so long life. 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning