How would I carry a variable from one function to main? My info is at the bottom.
Printable View
How would I carry a variable from one function to main? My info is at the bottom.
'Carry'? You could pass it by refrence..
How would I do that?
In the function declaration, derefrence the desired parameter with the 'address of' operand (&).
void myFunct(int &passedbyref, int notpassedbyref);
Then, just use the variable inside the function as you always would.
I meant from the function and then to main.
Not sure what you mean, perhaps something like this:
Code:datatype *function (void)
{
datatype *variable;
// do some stuff with the variable
// return address of variable to main
return variable;
}