Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Objectives: Pointer arithmetic, type casting, call by reference. Requirements: In this lab, five functions need to be implemented using the following function prototypes: 1. void
Objectives: Pointer arithmetic, type casting, call by reference. Requirements: In this lab, five functions need to be implemented using the following function prototypes: 1. void ** create2DArray(int numRows, int numCols, int elemSize); In this function, programmers need to create a 2D array like below: Num of Rows Num of Cols Num of Cols T[0][0] T[1][0] T[0][1] T [1][1] T[O][num Cols-1] T[1][num Cols-1] Num of Cols T[num Rows-1][0] T[numRows-1][1] ... T[numRows-1][num Cols-1] The number of rows needs to be stored before the array of row pointers as a double- precision number (double), and the number of columns needs to be stored before each row also as a double-precision number (double). These numbers should not be visible to users. 2. double getRowSize(void ** table); This function receives a 2D array of any type, and returns the number of rows in this 2D array, which is stored before row pointers. 3. double getColSize(void** table, int rowNo); This function receives a 2D array of any type, then returns the number of columns in the row that indicated by input variable "rowNo", or returns "-1" if the indicated row doesn't exist. "rowNo" is 0-based. 4. void printTable(void** table); This function receives a 2D array of any type and prints out all the values in this 2D array in row- wise order. In this section, all elements in the 2D array are integers. 5. void free Table(void** table); This function receives the 2D array, and frees ALL the previously allocated memories. Note: You can create your own testing (main) function in whichever way you prefer to test your functions. Your main function will NOT be graded in this lab. Objectives: Pointer arithmetic, type casting, call by reference. Requirements: In this lab, five functions need to be implemented using the following function prototypes: 1. void ** create2DArray(int numRows, int numCols, int elemSize); In this function, programmers need to create a 2D array like below: Num of Rows Num of Cols Num of Cols T[0][0] T[1][0] T[0][1] T [1][1] T[O][num Cols-1] T[1][num Cols-1] Num of Cols T[num Rows-1][0] T[numRows-1][1] ... T[numRows-1][num Cols-1] The number of rows needs to be stored before the array of row pointers as a double- precision number (double), and the number of columns needs to be stored before each row also as a double-precision number (double). These numbers should not be visible to users. 2. double getRowSize(void ** table); This function receives a 2D array of any type, and returns the number of rows in this 2D array, which is stored before row pointers. 3. double getColSize(void** table, int rowNo); This function receives a 2D array of any type, then returns the number of columns in the row that indicated by input variable "rowNo", or returns "-1" if the indicated row doesn't exist. "rowNo" is 0-based. 4. void printTable(void** table); This function receives a 2D array of any type and prints out all the values in this 2D array in row- wise order. In this section, all elements in the 2D array are integers. 5. void free Table(void** table); This function receives the 2D array, and frees ALL the previously allocated memories. Note: You can create your own testing (main) function in whichever way you prefer to test your functions. Your main function will NOT be graded in this lab
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started