I have a function that requires it to be void
and that a double pointer is returned from it by the argument.
void cracking::decompose(char input[][100], int size_S, double* &Atm, int* &ID, int &size_out);
{
vector<double> AtmD;
vector<int> XsD;
...
Atm = &AtmD[0];
ID = &XsD[0];
size_out = size(AtmD);
}
On Main it stays:
int main()
{
char oi[900][100] = { "1 0.5 C", "2 0.55 N", "3 .5 S" };
double* xAtm = NULL;
int* xXs = NULL;
int tamanho;
cracking calc;
calc.decompose(oi, 3, xAtm, xXs, tamanho);
return 0;
}
Although compiling it returns me completely wrong values. Is there any way to do this with the pointers?
In fact I realized that the pointers inside my function turn into junk when I return them to the main. Is there any way to keep pointers saved? For example, if I save the address 0x000000000029d680
in memory and it corresponds to 23.5, when I leave the function this address no longer corresponds to that value and turns to garbage, is there a way to keep this value?