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 :)

Answers


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.


Need Your Help

remove characters from string in c

c string memcpy

I'm having an issue removing characters from a string. I have been able to identify the characters to remove and store them as a new string but I would like a code that enables me to remove the new

IE 10 not rendering Japanese correctly

internet-explorer-10

I recently discovered an issue with IE10. We have a web page that displays English text beside a translation in Japanese. Some of the Japanese characters display as squares. In the view source page...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.