I have trouble in declaring variables in main() so that it can be passed to a C function - also declaring variables in C functions so that it can be returned to the main() without using the return statment. I know pointers are ofter used. Then arrays could also be used. The dimensions of the arrays do not always needs to be declared in the C function - but it seems the main() always want it be declared if it is an array - there are times, we do not the array size - I had a working code where one of the dimension of a 2D array was blank, var[][10], in a C function.
In this statement
int *j = 0
is j = 0 or address of j = 0? Why in main it has the received with &varm to correctly pass the value?
The help I am seeking is an illustration of these possible scenarios and preferably an explanation - could someone help?
If a C function mallocs a variable and does some computation - then you would want to free this variable. If you free, and the function intend passes the variable through the function call, will the variable would have become NULL before main() receives the benefits of computation? What do you do?
Thanks if you could help.