Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ : In this lab youll be using dynamically allocated character arrays to recreate some of the functionality of the string class. You can choose

C++ : In this lab youll be using dynamically allocated character arrays to recreate some of the functionality of the string class. You can choose whether to write this as a class or simply main() and a few functions.

Lab 4a: Creating the String

Ask the user how large a word they want to enter and then create an appropriately sized dynamically allocated character array. Once youve created the array, have the user enter their string and fill in your array letter by letter using the following code: (Youll need to replace word with whatever you called your pointer to your array.)

cout << "Please enter your word: ";

for (int i = 0; i < size; i++)

cin >> word[i];

Dont forget to deallocate (i.e. delete) the dynamically array at the end of main.

Lab 4b: Printing the String

Use array-style notation (i.e. word[i]) to create a function that will loop through your character array and print out the full string, one character at a time.

Lab 4c: Searching the String

Prompt the user for a letter to search for and then use pointer-style notation (i.e. *word) to search through your array character by character looking for the first instance of a particular letter in the string.

Lab 4d: Checking for a Palindrome

Use two pointers walking through your array to test whether your string is a palindrome or not (a palindrome reads the same forwards and backwards the 1st & last letters are the same, the 2nd & 2nd-to-last letters are the same ).

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_2

Step: 3

blur-text-image_3

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

c. How is trust demonstrated?

Answered: 1 week ago