arrays between functions, dependent on local variables
Here's essentially what my problem is:
In main, the program gets the user to enter two natural numbers, these are then passed to a function which creates an array with the larger of these two numbers as the maximum element, and does stuff to this array.
In main, I need access to this array again in order to print elements of it, and manipulate it etc.
e.g. if the user enters 5 and 7, then I need to create an array[7] in the function, do stuff to it, and then be able to use it in main again.
The only way I would really know how to make the array exist in both functions is to make it as a global variable, but as it's dependant on local variables in main (what the user inputs), I'm confused as to how I can make it so that I can use the array in both functions...
Or is there a way of changing the size of an array? So I could declare it globally, then change its size to whatever I need once the numbers have been entered.
Is there a way to do this?
Cheers for any help