Question: Lab 4-Pointers One of the useful things pointers allow us to do is to dynamically allocate memory only when we need it. In this lab,

 Lab 4-Pointers One of the useful things pointers allow us to

Lab 4-Pointers One of the useful things pointers allow us to do is to dynamically allocate memory only when we need it. In this lab, you will use pointers to dynamically allocate an array, and then manipulate that array through pointer arithmetic. Start by declaring a pointer to a string in the main function, and initialize it to NULL. Then, ask the user how many strings they would like to enter, and use your pointer to dynamically allocate an array of that user specified size. Next, pass that array, along with the size, into a function, fillArray..-). You should use a pointer parameter to a string to accept the array, Inside the function, use a loop to iterate through the array, prompting the user to enter a value at each element in the array. You should use pointer arithmetic and the pointer/offset notation to accomplish this (not the bracketed pointer/index, or array, notation) Back in the main, pass the newly-filled array and the size into another function, displayArray(-), which will similarly loop through the array and display it's contents. There are no classes or anything to worry about in this one - just pointers. When you are done, submit your completed.cpp file through Blackboard. Sample Screenshot CAUsers Lucian source repos Project Debug Project.exe How many data elements are there? 5 Enter the first string: 956-555-1337 Enter the first string: 956-555-2345 Enter the first string: 956-867-5309 Enter the first string: 956-110-1100 Enter the first string: 956-524-1748 Element 41: 956-555-1337 Element #2: 956-555-2345 Element #3: 956-867-5309 Element #4: 956-110-1100 Element 95: 956-524-1748 Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!