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:
- using a global variable To capture the matrix and define the size, the more you can expect.
- 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.
- This also indicates better and can be used dynamically allotted / free memory.
Comments
Post a Comment