Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 1 (3 pts): Create a C-style string that will hold a sentence/paragraph inputted by the user. You can make a static array for this,

Task 1 (3 pts): Create a C-style string that will hold a sentence/paragraph inputted by the user. You can make a static array for this, but make sure your getline has the appropriate length. Use cin.getline (array_name, num_chars_to_read) for C-style strings. What do you think may happen if you enter more characters than specified by num_chars_to_read in cin.getline ()? The code below may help this problem. if (cin.fail() { cin.ignore (256,' '); //get rid of everything leftover cin.clear(); //reset the failbit for the next cin } Task 2 (3 pts): Create an array of C++ strings for any N number of words that user wants to search for and read those words from the user. Ask the user how many words they want to search for. Create an array of that many words 7 C++ . Read each word from the user. Remember, you would use getline for C++ strings. getline (cin, word_array_name[i]); You need to have a main function that asks for a sentence/paragraph and for the N words. After getting inputs from the user, print out both arrays to check if they are working properly. Remember to check memory leaks as well.

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

Step: 3

blur-text-image

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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

Solve the following 1,4 3 2TT 5x- 1+ (15 x) dx 5X

Answered: 1 week ago

Question

What are the three kinds of research types? Explain each type.

Answered: 1 week ago