Misc questions about variables and arrays

I've got a couple of questions about storing and retrieving data.
Can variables be stored in one function and passed to another? How about passing it to main?
Since functions cannot pass more than 1 variable, I guess that an array is the best option?
How can I "cout" an array from a function to main?
Are there other way of storing info, other than variables or arrays?
I know that these are general questios but that's kinda where I am at with my knowledge.
Thanks, Andy
If your function is declared like this:
void MyFunction(bool& MyBool);

Then you are passing data into the function, and the function has the ability to change the original value. This let's the function calculate and "return" more than one value and of different types. Another way to do it is to pass the "address" of a value to a pointer in a function like so:
1
2
3
4
5
6
7
void MyFunction(bool* MyBool);
int main()
{
    bool a;
    MyFunction(&a);
    std::cout << a;
}


This let's MyFunction modify the original variable (a). You can do this with arrays, structures, or as many data types as you like.
Topic archived. No new replies allowed.