I have to use dynamic memory allocation to return a newly-created array from a
function. The return value cannot be a “dynamic array” (created by an ordinary
array declaration), because such an array cannot safely be accessed from outside the function
where it was declared. Memory space obtained from the malloc() function, however, can be
passed around from one function to another. The cost of this freedom is that you need to be
more careful with this explicitly allocated space; for example, you have to call free() when
you’re finished with it.
• You must call malloc() to create the space for the new array returned by your function.
• You must call free() in your main() function to release the space when you have
finished using it.
Write a function with this prototype:
double *rowmaxes(int N, double matrix[N][N]);
Rowmaxes() must return a new array containing in element i the largest element in row i of the
N×N matrix called matrix.
In the same file as your function, write a program (a main() function) that asks the user for
whatever input is needed to try out the function. Print the results. Don’t forget to free the
memory allocated in your function.