c - using values generated in main1() and using them in main2() -


If I have a program like c:

  void main1 () {} / * Note that these are not main * / zero main 2 () {} ... int main () {main1 (); Main2 (); Return 0; }  

I have some values ​​or matrix which is made in main 1 (), and I want to use this matrix in main2 (). How can we move these values: Because I have main subfunction and I have to generate a large matrix of unknown length in main 1 () and I have to use these matrix values ​​in main2 (). But I have no idea how can I do this? How can I store the matrix and use it in main2 ()? Thankyou:

There are several options:

  1. using a global variable To capture the matrix and define the size, the more you can expect.
  2. If you do not like the global variable, then just wrap the matrix inside a structure and use it as the parameter and return type.
  3. This also indicates better and can be used dynamically allotted / free memory.

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -