How do I pass back a local variable from a function to main, if said function already has a return value? Sorry for the question, I’m trying to make it as objective as possible for everyone, not just my case.
Specifically: I have a function called subtotal. There are two counting variables. One of them I returned with a return. The other I need to make available for use by my main() function.
edit: To clarify:
function something() {
float counter = 0.0;
int someOtherVar = 0;
// the work
return someOtherVar;
}
What I want to do is pass the counter float to main.
Pass a pointer to the extra return value as a parameter to the function.
And to call it:
Oftentimes, @Mat’s suggestion of packing all the return values into a
structis preferable.