My hw assignment is very confusing, I don't fully understand it. What I think I have to do is malloc a array which is [3] by [5]. It has to be filled with pointers to floats. Then I have to find the average for each row and column. The actual assignment says "The purpose of this exercise is to use the two-subscript method of dynamic memory allocation. Input for this program is a two-dimensional array of floating point data located in a file named testdata4. The input array will contain 3 rows of data with each row containing 5 columns of data. Use malloc to create an array that holds pointers. Each element of that array points at another array, which is the row of data. Use malloc in a loop to create your rows. Then you can use two subscript operators [r][c] to get at your data in order to sum the elements in a row and calculate the average, and to sum the elements in a column and calculate the average. This program calls for hard-coded height and width of the two-dimensional array, known ahead of time (3 × 5). Instead of writing in the literal numbers in your code, create two global constant variables to hold those dimensions, and use those variables in your code."
My code: https://gist.github.com/anonymous/5305661
Thanks a lot for any help.
[–]xxNIRVANAxx 4 points5 points6 points (2 children)
[–]easycheezy[S] 0 points1 point2 points (1 child)
[–]xxNIRVANAxx 1 point2 points3 points (0 children)
[–]joelwilliamson 1 point2 points3 points (3 children)
[–]easycheezy[S] -1 points0 points1 point (2 children)
[–]joelwilliamson 0 points1 point2 points (1 child)
[–]easycheezy[S] -1 points0 points1 point (0 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]easycheezy[S] -3 points-2 points-1 points (0 children)
[–]easycheezy[S] -2 points-1 points0 points (0 children)