Pointer to Pointer program

Hello guys, I found this exercise online and i need to do it for my class. I have NO CLUE. Please help
CS M10B - Topic A Project –
Due Tuesday 9/8

Write a program that implements the following diagram:

http://i66.tinypic.com/2h7nls2.png (link to the diagram)


Use new to allocate any memory wherever it can be used without incurring any memory leaks and will end up implementing the diagram. For the remainder, use already declared pointer variables where that must be done in order to implement the diagram. Thus there will be a mix where some pointers are dynamically allocated and others will simply be assigned addresses of existing variables. It is up to you to determine what a correct mix is.

The shaded boxes represent pointers. The unshaded boxes represent a dynamically allocated two dimensional int array. Your program cannot create named identifiers for any of the unnamed items. The number of rows and the number of columns will be user input. The ellipses in the diagram represent that the sizes of the rows and columns are variable. The vertical array is an array of pointers. Each of the vertical array elements points to a one dimensional array of integers. This is really what a two dimensional array is. While each integer array could be a different length (number of columns), that is a ragged array, for this project we will use a rectangular array. The box (pointer) pointed to by u and v points to the first element of the first row array.

In your program only refer to the integer array through the pointers represented by s and t. u and v will be used as per the example program output. When passing to functions you must always pass these pointers and use these identifiers in the functions. You cannot dereference actual parameters in a function call. Nor can you dereference pointers and assign them to variables just in order to work with them.

The “Memory Layout for C++ Part 2” document discusses levels of indirection. Each arrow in the above diagram represents a level of indirection. Each level of indirection corresponds to an “*” when using a pointer variable.

Further, your program is to have, at a minimum:
• An allocation function, called from main, which allocates and assigns all the memory. That is, the entire implementation of the diagram is in this function. This function will also get the values for rows and columns from the user.
• An input function, called by main. For accessing the array, the function must use only pointer/offset notation. Run TopicA.exe to see what this is supposed to look like. Remember to take operator precedence into account.
• A function to reverse the contents of each row. Called from main. For accessing the array, the function must use only array subscript notation. Remember to take operator precedence into account. If necessary, a separate array can be created to perform the reversal, although this is inefficient and unnecessary. This separate array must use the array class template. (The Extra Credit uses only one array.)
• A function to display the array. Called from main.
• A function to deallocate memory. Called from main
• No global variables.
• Appropriate use of & and const.
• Use C++ 11 uniform initialization where appropriate.

Run the example program TopicA.exe. The “Press Enter to end” prompt is part of your program to implement. (“Press any key to continue” is from Visual Studio and cannot be taken out.) Call your source code file TopicA.cpp.


Extra Credit (10 points)
As noted above, using a separate array to implement the reversal is inefficient and unnecessary. It is inefficient because a separate array must be created, the values copied into the array, and then the values copied back into the source array. The way this is usually done is to use the source array and reverse the values using only the source array. This way no extra array is created. The extra credit is to do it using only the source array. I suggest that you first work out the algorithm by hand using pencil and paper. The program status must state that it is the extra credit version in order to get the extra credit.
Please note that this is not a homework site. We won't do your homework for you. The purpose of homework is that you learn by doing. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't have a clue", then you should go back to basics and study again.
I'm sorry to say that this is a really horrible assignment. It's so bad that nobody wanted to help the last time it was posted:
http://www.cplusplus.com/forum/general/109612/
Topic archived. No new replies allowed.