Matrix multiplication - Pointers and arrays
I'm fairly new to C programming, so bear with me :) I have a main() which generates a 2D-array (aka a matrix). I tried to define an "external" function matrix_multipl(), which takes two matrices from main(), multiplies them and returns them, which of course caused problems (you can't return an array from a function).
So my approach is the following and I want to know whether I understand the process correctly:
I generate the arrays (first[m][n], second[o][p] and outcome[m][p] matrices) inside main and from there, I use only pointers to that array, so if I call the pointer to that array inside matrix_multipl(), it essentially runs back to the main, fetches the respective value from the array, does something with it (matrix multiplications) and finally takes the computed value, runs again to the main() and writes the result into the outcome[m][p] matrix, which stayed all the time inside main() and therefore didn't need to be "returned"?
I hope I got it right, because that sounds absolutely logical and quite useful, because it prevents shoving big arrays back and forth :)
I'm not sure I fully understand what you mean by 'runs back to main()', but yes, what you seem to be talking about is commonly referred to as 'passing by reference', and is a commonly used technique in C programming.