Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Programming Purpose: To gain an understanding of pointers while dynamically allocating arrays and demonstrate passing and returning pointers within functions. You will also review

C++ Programming

Purpose: To gain an understanding of pointers while dynamically allocating arrays and demonstrate passing and returning pointers within functions. You will also review character arrays now that we have a better understanding of memory mapping.

Write a function getString that has a local char array of 80 elements. The function should ask the user to enter a sentence and store the sentence in the array. Then the function should dynamically allocate a char array just large enough to hold the sentence along with the null terminator. It should copy the sentence to the dynamically allocated array and then return a pointer to the array.

o Take the program one step further by creating another function revString that will create a copy of the sentence except it will reverse the elements values (the characters) of the array. Important, remember to leave the null terminator at the end of the array. The function should return the pointer of the new array and your main function will then display the reversed sentence below your original string.

Write another function named elementShifter. The elementShifter function will accept 2 arguments, an int array and the array size. The function will then create a new array that is three elements larger in size than the one that was passed into the function. The first element (element 0) of the new array will be set to 100 and the second one will be set to 255, the third will be 377. Element 0 of the of the argument array will be copied to Element 3 of the new array and Element 1 of the argument array will be copied to the Element 4 of the new array and so forth. The function should return a pointer to the new array.

o Create a showIntArray function that will print the arrays contents to the screen. You should then call it twice to show both arrays, the original and then the new one from your driver program.

Write a driver program that tests your functions. You do not need to go overboard with your prompts, but your program should tell us what is happening. You should also add comments to your program as needed.

Note: you must have getString and revString functions working perfectly.

Add another function to your program that will output your sentence (from getString) in pig-Latin.

Make sure your comments reflect the additional functionality in the comment headings.

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2016 Riva Del Garda Italy September 19 23 2016 Proceedings Part 1 Lnai 9851

Authors: Paolo Frasconi ,Niels Landwehr ,Giuseppe Manco ,Jilles Vreeken

1st Edition

3319461273, 978-3319461274

More Books

Students also viewed these Databases questions