Lets say I have the following code.
double *return_array(void) {
double foo[2];
foo[0] = 5;
foo[1] = 6;
cout << foo << endl;
cout << foo[0] << endl << foo[1] << endl;
return foo;
}
double *bar = return_array()
cout << bar << endl;
cout << bar[0] << endl << bar[1] << endl;
Now, bar and foo are still the same pointer but what was there has changed completely. How can I get around this? Basically, I need to pass 6 or 9 doubles from a function. What should I do?