Hello all,
I am fairly new to c, coming from a Java background. I am working on a mathematical program and I have a function that needs to return a 2-d array. After some web searching, I have determined that in c, it is better to just pass the array in the function. Since arrays are passed by reference, I expected for the updated array to be passed back with the correct values filled in, however, only the first row of the array is returned (with the rest of the rows filled with zeroes) upon returning from the function. I know that the values are being properly filled in since I verify that before returning from the function (that fills the array). Sorry for the long post, just trying to explain the situation. Below is a simplified version of the code that I'm using
Sample output:
any help is appreciated
I am fairly new to c, coming from a Java background. I am working on a mathematical program and I have a function that needs to return a 2-d array. After some web searching, I have determined that in c, it is better to just pass the array in the function. Since arrays are passed by reference, I expected for the updated array to be passed back with the correct values filled in, however, only the first row of the array is returned (with the rest of the rows filled with zeroes) upon returning from the function. I know that the values are being properly filled in since I verify that before returning from the function (that fills the array). Sorry for the long post, just trying to explain the situation. Below is a simplified version of the code that I'm using
Code:
void createVectorSeries(float input[], float output[][COLS]) { /* populate the output array */ } void main() { float output[ROWS][COLS] ; /* fill input array */ createVectorSeries(input, output) ;
Code:
0.3 0.4 0.5 0.6 0 0 0 0 0 0 0 0
Comment