I have an array that was created within a function, I want to use it in a different function but can't seem to figure out how.
If it helps at all, here is the function with the array in it. I want to use roll[] within a different function.
int roll_5_array(void)
{
int i = 0, roll[5]; //Declaring array
for (; i < 5; i = i + 1) //Repeat 5 times
{
int outcome = 0;
outcome = roll_die(); //Roll die
roll[i] = outcome;
}
}
With my current knowledge, I can only come up with a few possible solutions to this:
- Make the array global, which seems unnecessary and redundant.
- Pass the array as a pointer, if that's even possible.